src/Infrastructure/Controller/Admin/BaseController.php line 10

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Infrastructure\Controller\Admin;
  4. use AlterPHP\EasyAdminExtensionBundle\Controller\EasyAdminController;
  5. use Symfony\Component\HttpFoundation\RedirectResponse;
  6. use Symfony\Component\PropertyAccess\PropertyAccess;
  7. class BaseController extends EasyAdminController
  8. {
  9.     protected function redirectToReferrer(): RedirectResponse
  10.     {
  11.         $action $this->request->request->get('submit-action');
  12.         $refererAction $this->request->query->get('action');
  13.         if ($action && $action === "submit-without-leave"  && $this->isActionAllowed('edit')) {
  14.             if (\in_array($refererAction, ['new''edit'])) {
  15.                 return $this->redirectToRoute('easyadmin', [
  16.                     'action' => 'edit',
  17.                     'entity' => $this->entity['name'],
  18.                     'menuIndex' => $this->request->query->get('menuIndex'),
  19.                     'submenuIndex' => $this->request->query->get('submenuIndex'),
  20.                     'id' => ('new' === $refererAction)
  21.                         ? PropertyAccess::createPropertyAccessor()->getValue($this->request->attributes->get('easyadmin')['item'], $this->entity['primary_key_field_name'])
  22.                         : $this->request->query->get('id'),
  23.                 ]);
  24.             }
  25.         }
  26.         return parent::redirectToReferrer();
  27.     }
  28. }