[ 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\Compiler\CompilerPassInterface; 15 use Symfony\Component\DependencyInjection\ContainerBuilder; 16 use Symfony\Component\DependencyInjection\Reference; 17 18 /** 19 * Adds services tagged kernel.fragment_renderer as HTTP content rendering strategies. 20 * 21 * @author Fabien Potencier <fabien@symfony.com> 22 */ 23 class FragmentRendererPass implements CompilerPassInterface 24 { 25 private $handlerService; 26 private $rendererTag; 27 28 /** 29 * @param string $handlerService Service name of the fragment handler in the container 30 * @param string $rendererTag Tag name used for fragments 31 */ 32 public function __construct($handlerService = 'fragment.handler', $rendererTag = 'kernel.fragment_renderer') 33 { 34 $this->handlerService = $handlerService; 35 $this->rendererTag = $rendererTag; 36 } 37 38 public function process(ContainerBuilder $container) 39 { 40 if (!$container->hasDefinition($this->handlerService)) { 41 return; 42 } 43 44 $definition = $container->getDefinition($this->handlerService); 45 foreach ($container->findTaggedServiceIds($this->rendererTag) as $id => $tags) { 46 $def = $container->getDefinition($id); 47 if (!$def->isPublic()) { 48 throw new \InvalidArgumentException(sprintf('The service "%s" must be public as fragment renderer are lazy-loaded.', $id)); 49 } 50 51 if ($def->isAbstract()) { 52 throw new \InvalidArgumentException(sprintf('The service "%s" must not be abstract as fragment renderer are lazy-loaded.', $id)); 53 } 54 55 $class = $container->getParameterBag()->resolveValue($def->getClass()); 56 $interface = 'Symfony\Component\HttpKernel\Fragment\FragmentRendererInterface'; 57 58 if (!is_subclass_of($class, $interface)) { 59 if (!class_exists($class, false)) { 60 throw new \InvalidArgumentException(sprintf('Class "%s" used for service "%s" cannot be found.', $class, $id)); 61 } 62 63 throw new \InvalidArgumentException(sprintf('Service "%s" must implement interface "%s".', $id, $interface)); 64 } 65 66 foreach ($tags as $tag) { 67 if (!isset($tag['alias'])) { 68 @trigger_error(sprintf('Service "%s" will have to define the "alias" attribute on the "%s" tag as of Symfony 3.0.', $id, $this->rendererTag), E_USER_DEPRECATED); 69 70 // register the handler as a non-lazy-loaded one 71 $definition->addMethodCall('addRenderer', array(new Reference($id))); 72 } else { 73 $definition->addMethodCall('addRendererService', array($tag['alias'], $id)); 74 } 75 } 76 } 77 } 78 }
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 |