matomo
/
app
/
vendor
/
prefixed
/
symfony
/
http-kernel
/
DependencyInjection
/
LazyLoadingFragmentHandler.php
AddAnnotatedClassesToCachePass.php
1 year ago
ConfigurableExtension.php
2 years ago
ControllerArgumentValueResolverPass.php
2 years ago
Extension.php
2 years ago
FragmentRendererPass.php
1 year ago
LazyLoadingFragmentHandler.php
1 year ago
LoggerPass.php
1 year ago
MergeExtensionConfigurationPass.php
2 years ago
RegisterControllerArgumentLocatorsPass.php
1 year ago
RegisterLocaleAwareServicesPass.php
2 years ago
RemoveEmptyControllerArgumentLocatorsPass.php
1 year ago
ResettableServicePass.php
1 year ago
ServicesResetter.php
2 years ago
LazyLoadingFragmentHandler.php
45 lines
| 1 | <?php |
| 2 | |
| 3 | /* |
| 4 | * This file is part of the Symfony package. |
| 5 | * |
| 6 | * (c) Fabien Potencier <fabien@symfony.com> |
| 7 | * |
| 8 | * For the full copyright and license information, please view the LICENSE |
| 9 | * file that was distributed with this source code. |
| 10 | */ |
| 11 | namespace Matomo\Dependencies\Symfony\Component\HttpKernel\DependencyInjection; |
| 12 | |
| 13 | use Matomo\Dependencies\Psr\Container\ContainerInterface; |
| 14 | use Matomo\Dependencies\Symfony\Component\HttpFoundation\RequestStack; |
| 15 | use Matomo\Dependencies\Symfony\Component\HttpKernel\Fragment\FragmentHandler; |
| 16 | /** |
| 17 | * Lazily loads fragment renderers from the dependency injection container. |
| 18 | * |
| 19 | * @author Fabien Potencier <fabien@symfony.com> |
| 20 | */ |
| 21 | class LazyLoadingFragmentHandler extends FragmentHandler |
| 22 | { |
| 23 | private $container; |
| 24 | /** |
| 25 | * @var array<string, bool> |
| 26 | */ |
| 27 | private $initialized = []; |
| 28 | public function __construct(ContainerInterface $container, RequestStack $requestStack, bool $debug = \false) |
| 29 | { |
| 30 | $this->container = $container; |
| 31 | parent::__construct($requestStack, [], $debug); |
| 32 | } |
| 33 | /** |
| 34 | * {@inheritdoc} |
| 35 | */ |
| 36 | public function render($uri, string $renderer = 'inline', array $options = []) |
| 37 | { |
| 38 | if (!isset($this->initialized[$renderer]) && $this->container->has($renderer)) { |
| 39 | $this->addRenderer($this->container->get($renderer)); |
| 40 | $this->initialized[$renderer] = \true; |
| 41 | } |
| 42 | return parent::render($uri, $renderer, $options); |
| 43 | } |
| 44 | } |
| 45 |