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/symfony/http-kernel/Fragment/FragmentHandler.php line 84

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of the Symfony package.
  4.  *
  5.  * (c) Fabien Potencier <fabien@symfony.com>
  6.  *
  7.  * For the full copyright and license information, please view the LICENSE
  8.  * file that was distributed with this source code.
  9.  */
  10. namespace Symfony\Component\HttpKernel\Fragment;
  11. use Symfony\Component\HttpFoundation\RequestStack;
  12. use Symfony\Component\HttpFoundation\Response;
  13. use Symfony\Component\HttpFoundation\StreamedResponse;
  14. use Symfony\Component\HttpKernel\Controller\ControllerReference;
  15. /**
  16.  * Renders a URI that represents a resource fragment.
  17.  *
  18.  * This class handles the rendering of resource fragments that are included into
  19.  * a main resource. The handling of the rendering is managed by specialized renderers.
  20.  *
  21.  * @author Fabien Potencier <fabien@symfony.com>
  22.  *
  23.  * @see FragmentRendererInterface
  24.  */
  25. class FragmentHandler
  26. {
  27.     private $debug;
  28.     private $renderers = [];
  29.     private $requestStack;
  30.     /**
  31.      * @param FragmentRendererInterface[] $renderers An array of FragmentRendererInterface instances
  32.      * @param bool                        $debug     Whether the debug mode is enabled or not
  33.      */
  34.     public function __construct(RequestStack $requestStack, array $renderers = [], bool $debug false)
  35.     {
  36.         $this->requestStack $requestStack;
  37.         foreach ($renderers as $renderer) {
  38.             $this->addRenderer($renderer);
  39.         }
  40.         $this->debug $debug;
  41.     }
  42.     /**
  43.      * Adds a renderer.
  44.      */
  45.     public function addRenderer(FragmentRendererInterface $renderer)
  46.     {
  47.         $this->renderers[$renderer->getName()] = $renderer;
  48.     }
  49.     /**
  50.      * Renders a URI and returns the Response content.
  51.      *
  52.      * Available options:
  53.      *
  54.      *  * ignore_errors: true to return an empty string in case of an error
  55.      *
  56.      * @param string|ControllerReference $uri A URI as a string or a ControllerReference instance
  57.      *
  58.      * @return string|null The Response content or null when the Response is streamed
  59.      *
  60.      * @throws \InvalidArgumentException when the renderer does not exist
  61.      * @throws \LogicException           when no master request is being handled
  62.      */
  63.     public function render($uristring $renderer 'inline', array $options = [])
  64.     {
  65.         if (!isset($options['ignore_errors'])) {
  66.             $options['ignore_errors'] = !$this->debug;
  67.         }
  68.         if (!isset($this->renderers[$renderer])) {
  69.             throw new \InvalidArgumentException(sprintf('The "%s" renderer does not exist.'$renderer));
  70.         }
  71.         if (!$request $this->requestStack->getCurrentRequest()) {
  72.             throw new \LogicException('Rendering a fragment can only be done when handling a Request.');
  73.         }
  74.         return $this->deliver($this->renderers[$renderer]->render($uri$request$options));
  75.     }
  76.     /**
  77.      * Delivers the Response as a string.
  78.      *
  79.      * When the Response is a StreamedResponse, the content is streamed immediately
  80.      * instead of being returned.
  81.      *
  82.      * @return string|null The Response content or null when the Response is streamed
  83.      *
  84.      * @throws \RuntimeException when the Response is not successful
  85.      */
  86.     protected function deliver(Response $response)
  87.     {
  88.         if (!$response->isSuccessful()) {
  89.             throw new \RuntimeException(sprintf('Error when rendering "%s" (Status code is %d).'$this->requestStack->getCurrentRequest()->getUri(), $response->getStatusCode()));
  90.         }
  91.         if (!$response instanceof StreamedResponse) {
  92.             return $response->getContent();
  93.         }
  94.         $response->sendContent();
  95.         return null;
  96.     }
  97. }