Deprecated: Return type of Google\Model::offsetExists($offset) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/html/sanralsmme/vendor/google/apiclient/src/Model.php on line 256

Deprecated: Return type of Google\Model::offsetGet($offset) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/html/sanralsmme/vendor/google/apiclient/src/Model.php on line 261

Deprecated: Return type of Google\Model::offsetSet($offset, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/html/sanralsmme/vendor/google/apiclient/src/Model.php on line 268

Deprecated: Return type of Google\Model::offsetUnset($offset) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/html/sanralsmme/vendor/google/apiclient/src/Model.php on line 278

Deprecated: Return type of Google\Collection::current() should either be compatible with Iterator::current(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/html/sanralsmme/vendor/google/apiclient/src/Collection.php on line 22

Deprecated: Return type of Google\Collection::next() should either be compatible with Iterator::next(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/html/sanralsmme/vendor/google/apiclient/src/Collection.php on line 38

Deprecated: Return type of Google\Collection::key() should either be compatible with Iterator::key(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/html/sanralsmme/vendor/google/apiclient/src/Collection.php on line 30

Deprecated: Return type of Google\Collection::valid() should either be compatible with Iterator::valid(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/html/sanralsmme/vendor/google/apiclient/src/Collection.php on line 43

Deprecated: Return type of Google\Collection::rewind() should either be compatible with Iterator::rewind(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/html/sanralsmme/vendor/google/apiclient/src/Collection.php on line 14

Deprecated: Return type of Google\Collection::count() should either be compatible with Countable::count(): int, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/html/sanralsmme/vendor/google/apiclient/src/Collection.php on line 49
Symfony Profiler

vendor/easycorp/easyadmin-bundle/src/EventListener/ExceptionListener.php line 35

Open in your IDE?
  1. <?php
  2. namespace EasyCorp\Bundle\EasyAdminBundle\EventListener;
  3. use EasyCorp\Bundle\EasyAdminBundle\Exception\BaseException;
  4. use EasyCorp\Bundle\EasyAdminBundle\Exception\FlattenException;
  5. use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProvider;
  6. use Symfony\Component\HttpFoundation\Response;
  7. use Symfony\Component\HttpKernel\Event\ExceptionEvent;
  8. use Twig\Environment;
  9. use Twig\Error\RuntimeError;
  10. /**
  11.  * This listener allows to display customized error pages in the production
  12.  * environment.
  13.  *
  14.  * @internal
  15.  *
  16.  * @author Javier Eguiluz <javier.eguiluz@gmail.com>
  17.  * @author Maxime Steinhausser <maxime.steinhausser@gmail.com>
  18.  */
  19. final class ExceptionListener
  20. {
  21.     private $kernelDebug;
  22.     private $adminContextProvider;
  23.     private $twig;
  24.     public function __construct(bool $kernelDebugAdminContextProvider $adminContextProviderEnvironment $twig)
  25.     {
  26.         $this->kernelDebug $kernelDebug;
  27.         $this->adminContextProvider $adminContextProvider;
  28.         $this->twig $twig;
  29.     }
  30.     public function onKernelException(ExceptionEvent $event)
  31.     {
  32.         $exception $event->getThrowable();
  33.         if ($this->kernelDebug && $exception instanceof RuntimeError && 'Variable "ea" does not exist.' === $exception->getRawMessage()) {
  34.             $exception->appendMessage($this->getEaVariableExceptionMessage());
  35.             return;
  36.         }
  37.         if ($this->kernelDebug || !$exception instanceof BaseException) {
  38.             return;
  39.         }
  40.         // TODO: check why these custom error pages don't work
  41.         $event->setResponse($this->createExceptionResponse(FlattenException::create($exception)));
  42.     }
  43.     public function createExceptionResponse(FlattenException $exception): Response
  44.     {
  45.         $context $this->adminContextProvider->getContext();
  46.         $exceptionTemplatePath null === $context '@EasyAdmin/exception.html.twig' $context->getTemplatePath('exception');
  47.         $layoutTemplatePath null === $context '@EasyAdmin/layout.html.twig' $context->getTemplatePath('layout');
  48.         return new Response($this->twig->render($exceptionTemplatePath, [
  49.             'exception' => $exception,
  50.             'layout_template_path' => $layoutTemplatePath,
  51.         ]), $exception->getStatusCode());
  52.     }
  53.     private function getEaVariableExceptionMessage(): string
  54.     {
  55.         return <<<MESSAGE
  56. The "ea" variable stores the admin context (menu items, actions, fields, etc.) and it's created automatically for requests served by EasyAdmin.
  57. If you are seeing this error, you are trying to use some EasyAdmin features in a request not served by EasyAdmin. For example, some of your custom actions may be trying to render or extend from one of the templates provided EasyAdmin.
  58. Your request must meet one of these conditions to be served by EasyAdmin (and to have the "ea" variable defined):
  59. 1) It must be run by a controller that implements DashboardControllerInterface. This is done automatically for all actions and CRUD controllers associated to your dashboard.
  60. 2) It must contain an "eaContext" query string parameter that identifies the Dashboard associated to this request (this parameter is automatically added by EasyAdmin when creating menu items that link to custom Symfony routes).
  61. MESSAGE;
  62.     }
  63. }