[ Index ] |
PHP Cross Reference of phpBB-3.2.11-deutsch |
[Summary view] [Print] [Text view]
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 12 namespace Symfony\Component\HttpKernel\DependencyInjection; 13 14 use Symfony\Component\DependencyInjection\ContainerInterface; 15 use Symfony\Component\HttpFoundation\RequestStack; 16 use Symfony\Component\HttpKernel\Fragment\FragmentHandler; 17 18 /** 19 * Lazily loads fragment renderers from the dependency injection container. 20 * 21 * @author Fabien Potencier <fabien@symfony.com> 22 */ 23 class LazyLoadingFragmentHandler extends FragmentHandler 24 { 25 private $container; 26 private $rendererIds = array(); 27 28 /** 29 * RequestStack will become required in 3.0. 30 * 31 * @param ContainerInterface $container A container 32 * @param RequestStack $requestStack The Request stack that controls the lifecycle of requests 33 * @param bool $debug Whether the debug mode is enabled or not 34 */ 35 public function __construct(ContainerInterface $container, $requestStack = null, $debug = false) 36 { 37 $this->container = $container; 38 39 if ((null !== $requestStack && !$requestStack instanceof RequestStack) || $debug instanceof RequestStack) { 40 $tmp = $debug; 41 $debug = $requestStack; 42 $requestStack = \func_num_args() < 3 ? null : $tmp; 43 44 @trigger_error('The '.__METHOD__.' method now requires a RequestStack to be given as second argument as '.__CLASS__.'::setRequest method will not be supported anymore in 3.0.', E_USER_DEPRECATED); 45 } elseif (!$requestStack instanceof RequestStack) { 46 @trigger_error('The '.__METHOD__.' method now requires a RequestStack instance as '.__CLASS__.'::setRequest method will not be supported anymore in 3.0.', E_USER_DEPRECATED); 47 } 48 49 parent::__construct($requestStack, array(), $debug); 50 } 51 52 /** 53 * Adds a service as a fragment renderer. 54 * 55 * @param string $name The service name 56 * @param string $renderer The render service id 57 */ 58 public function addRendererService($name, $renderer) 59 { 60 $this->rendererIds[$name] = $renderer; 61 } 62 63 /** 64 * {@inheritdoc} 65 */ 66 public function render($uri, $renderer = 'inline', array $options = array()) 67 { 68 if (isset($this->rendererIds[$renderer])) { 69 $this->addRenderer($this->container->get($this->rendererIds[$renderer])); 70 71 unset($this->rendererIds[$renderer]); 72 } 73 74 return parent::render($uri, $renderer, $options); 75 } 76 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Nov 11 20:33:01 2020 | Cross-referenced by PHPXref 0.7.1 |