Commit f8d3edff by Damien Moulard

Merge branch '5443-probleme-export-flux' into 'develop'

increase php time limit in export controller that overrides default…

See merge request cooperatic/kohinos-tav!46
parents 25217d8d bbb4d42d
...@@ -460,7 +460,7 @@ services: ...@@ -460,7 +460,7 @@ services:
admin.flux.gerer: admin.flux.gerer:
class: App\Admin\FluxAdmin class: App\Admin\FluxAdmin
arguments: [~, App\Entity\Flux, ~] arguments: [~, App\Entity\Flux, 'App\Controller\CRUD\CRUDController']
tags: tags:
- name: sonata.admin - name: sonata.admin
manager_type: orm manager_type: orm
......
...@@ -7,6 +7,8 @@ use Sonata\AdminBundle\Datagrid\ProxyQueryInterface; ...@@ -7,6 +7,8 @@ use Sonata\AdminBundle\Datagrid\ProxyQueryInterface;
use Symfony\Component\Form\FormRenderer; use Symfony\Component\Form\FormRenderer;
use Symfony\Component\Form\FormView; use Symfony\Component\Form\FormView;
use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
class CRUDController extends Controller class CRUDController extends Controller
{ {
...@@ -127,53 +129,60 @@ class CRUDController extends Controller ...@@ -127,53 +129,60 @@ class CRUDController extends Controller
], null); ], null);
} }
// /**
// * @inheritdoc /**
// */ * Export data to specified format.
// public function exportAction(Request $request) *
// { * @throws AccessDeniedException If access is not granted
// $this->admin->checkAccess('export'); * @throws \RuntimeException If the export format is invalid
*
// $format = $request->get('format'); */
public function exportAction(Request $request)
// // // NEXT_MAJOR: remove the check {
// // if (!$this->has('sonata.admin.admin_exporter')) { set_time_limit(300); //set php time limit to 5 minutes to make sure big exports can be done
// // @trigger_error( $this->admin->checkAccess('export');
// // '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 $format = $request->get('format');
// // );
// // $allowedExportFormats = (array) $this->admin->getExportFormats(); // NEXT_MAJOR: remove the check
if (!$this->has('sonata.admin.admin_exporter')) {
// // $class = (string) $this->admin->getClass(); @trigger_error(
// // $filename = sprintf( '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.',
// // 'export_%s_%s.%s', \E_USER_DEPRECATED
// // strtolower((string) substr($class, strripos($class, '\\') + 1)), );
// // date('Y_m_d_H_i_s', strtotime('now')), $allowedExportFormats = (array) $this->admin->getExportFormats();
// // $format
// // ); $class = (string) $this->admin->getClass();
// // $exporter = $this->get('sonata.admin.exporter'); $filename = sprintf(
// // } else { 'export_%s_%s.%s',
// $adminExporter = $this->get('sonata.admin.admin_exporter'); strtolower((string) substr($class, strripos($class, '\\') + 1)),
// $allowedExportFormats = $adminExporter->getAvailableFormats($this->admin); date('Y_m_d_H_i_s', strtotime('now')),
// $filename = $adminExporter->getExportFilename($this->admin, $format); $format
// $exporter = $this->get('sonata.exporter.exporter'); );
// // } $exporter = $this->get('sonata.admin.exporter');
} else {
// if (!\in_array($format, $allowedExportFormats, true)) { $adminExporter = $this->get('sonata.admin.admin_exporter');
// throw new \RuntimeException(sprintf( $allowedExportFormats = $adminExporter->getAvailableFormats($this->admin);
// 'Export in format `%s` is not allowed for class: `%s`. Allowed formats are: `%s`', $filename = $adminExporter->getExportFilename($this->admin, $format);
// $format, $exporter = $this->get('sonata.exporter.exporter');
// $this->admin->getClass(), }
// implode(', ', $allowedExportFormats)
// )); if (!\in_array($format, $allowedExportFormats, true)) {
// } throw new \RuntimeException(sprintf(
'Export in format `%s` is not allowed for class: `%s`. Allowed formats are: `%s`',
// return $exporter->getResponse( $format,
// $format, $this->admin->getClass(),
// $filename, implode(', ', $allowedExportFormats)
// $this->admin->getDataSourceIterator() ));
// ); }
// }
return $exporter->getResponse(
$format,
$filename,
$this->admin->getDataSourceIterator()
);
}
public function deleteAction($id) 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