Project 'cooperatic/kohinos-tav' was moved to 'agplv3/kohinos-tav'. Please update any links and bookmarks that may still have the old path.
Commit bbb4d42d by Yvon

increase php time limit in export controller that overrides default…

increase php time limit in export controller that overrides default sonata-project one (inspiring commit : 039e23cb)
parent 33462cd4
......@@ -460,7 +460,7 @@ services:
admin.flux.gerer:
class: App\Admin\FluxAdmin
arguments: [~, App\Entity\Flux, ~]
arguments: [~, App\Entity\Flux, 'App\Controller\CRUD\CRUDController']
tags:
- name: sonata.admin
manager_type: orm
......
......@@ -7,6 +7,8 @@ use Sonata\AdminBundle\Datagrid\ProxyQueryInterface;
use Symfony\Component\Form\FormRenderer;
use Symfony\Component\Form\FormView;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
class CRUDController extends Controller
{
......@@ -127,53 +129,60 @@ class CRUDController extends Controller
], null);
}
// /**
// * @inheritdoc
// */
// public function exportAction(Request $request)
// {
// $this->admin->checkAccess('export');
// $format = $request->get('format');
// // // NEXT_MAJOR: remove the check
// // if (!$this->has('sonata.admin.admin_exporter')) {
// // @trigger_error(
// // 'Not registering the exporter bundle is deprecated since version 3.14. You must register it to be able to use the export action in 4.0.',
// // \E_USER_DEPRECATED
// // );
// // $allowedExportFormats = (array) $this->admin->getExportFormats();
// // $class = (string) $this->admin->getClass();
// // $filename = sprintf(
// // 'export_%s_%s.%s',
// // strtolower((string) substr($class, strripos($class, '\\') + 1)),
// // date('Y_m_d_H_i_s', strtotime('now')),
// // $format
// // );
// // $exporter = $this->get('sonata.admin.exporter');
// // } else {
// $adminExporter = $this->get('sonata.admin.admin_exporter');
// $allowedExportFormats = $adminExporter->getAvailableFormats($this->admin);
// $filename = $adminExporter->getExportFilename($this->admin, $format);
// $exporter = $this->get('sonata.exporter.exporter');
// // }
// if (!\in_array($format, $allowedExportFormats, true)) {
// throw new \RuntimeException(sprintf(
// 'Export in format `%s` is not allowed for class: `%s`. Allowed formats are: `%s`',
// $format,
// $this->admin->getClass(),
// implode(', ', $allowedExportFormats)
// ));
// }
// return $exporter->getResponse(
// $format,
// $filename,
// $this->admin->getDataSourceIterator()
// );
// }
/**
* Export data to specified format.
*
* @throws AccessDeniedException If access is not granted
* @throws \RuntimeException If the export format is invalid
*
*/
public function exportAction(Request $request)
{
set_time_limit(300); //set php time limit to 5 minutes to make sure big exports can be done
$this->admin->checkAccess('export');
$format = $request->get('format');
// NEXT_MAJOR: remove the check
if (!$this->has('sonata.admin.admin_exporter')) {
@trigger_error(
'Not registering the exporter bundle is deprecated since version 3.14. You must register it to be able to use the export action in 4.0.',
\E_USER_DEPRECATED
);
$allowedExportFormats = (array) $this->admin->getExportFormats();
$class = (string) $this->admin->getClass();
$filename = sprintf(
'export_%s_%s.%s',
strtolower((string) substr($class, strripos($class, '\\') + 1)),
date('Y_m_d_H_i_s', strtotime('now')),
$format
);
$exporter = $this->get('sonata.admin.exporter');
} else {
$adminExporter = $this->get('sonata.admin.admin_exporter');
$allowedExportFormats = $adminExporter->getAvailableFormats($this->admin);
$filename = $adminExporter->getExportFilename($this->admin, $format);
$exporter = $this->get('sonata.exporter.exporter');
}
if (!\in_array($format, $allowedExportFormats, true)) {
throw new \RuntimeException(sprintf(
'Export in format `%s` is not allowed for class: `%s`. Allowed formats are: `%s`',
$format,
$this->admin->getClass(),
implode(', ', $allowedExportFormats)
));
}
return $exporter->getResponse(
$format,
$filename,
$this->admin->getDataSourceIterator()
);
}
public function deleteAction($id)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment