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/CrudResponseListener.php line 26

Open in your IDE?
  1. <?php
  2. namespace EasyCorp\Bundle\EasyAdminBundle\EventListener;
  3. use EasyCorp\Bundle\EasyAdminBundle\Config\KeyValueStore;
  4. use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProvider;
  5. use Symfony\Component\Form\FormInterface;
  6. use Symfony\Component\HttpFoundation\Response;
  7. use Symfony\Component\HttpKernel\Event\ViewEvent;
  8. use Twig\Environment;
  9. /**
  10.  * @author Javier Eguiluz <javier.eguiluz@gmail.com>
  11.  */
  12. final class CrudResponseListener
  13. {
  14.     private $adminContextProvider;
  15.     private $twig;
  16.     public function __construct(AdminContextProvider $adminContextProviderEnvironment $twig)
  17.     {
  18.         $this->adminContextProvider $adminContextProvider;
  19.         $this->twig $twig;
  20.     }
  21.     public function onKernelView(ViewEvent $event)
  22.     {
  23.         $responseParameters $event->getControllerResult();
  24.         if (null === $responseParameters || !$responseParameters instanceof KeyValueStore) {
  25.             return;
  26.         }
  27.         if (!$responseParameters->has('templateName') && !$responseParameters->has('templatePath')) {
  28.             throw new \RuntimeException('The KeyValueStore object returned by CrudController actions must include either a "templateName" or a "templatePath" parameter to define the template used to render the action result.');
  29.         }
  30.         $templateParameters $responseParameters->all();
  31.         $templatePath \array_key_exists('templatePath'$templateParameters)
  32.             ? $templateParameters['templatePath']
  33.             : $this->adminContextProvider->getContext()->getTemplatePath($templateParameters['templateName']);
  34.         // to make parameters easier to modify, we pass around FormInterface objects
  35.         // so we must convert those values to FormView before rendering the template
  36.         foreach ($templateParameters as $paramName => $paramValue) {
  37.             if ($paramValue instanceof FormInterface) {
  38.                 $templateParameters[$paramName] = $paramValue->createView();
  39.             }
  40.         }
  41.         $event->setResponse(new Response($this->twig->render($templatePath$templateParameters)));
  42.     }
  43. }