Verzeichnisstruktur phpBB-3.3.15
- Veröffentlicht
- 28.08.2024
So funktioniert es
|
Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück |
Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis. |
|
(Beispiel Datei-Icons)
|
Auf das Icon klicken um den Quellcode anzuzeigen |
FragmentRendererPass.php
01 <?php
02
03 /*
04 * This file is part of the Symfony package.
05 *
06 * (c) Fabien Potencier <fabien@symfony.com>
07 *
08 * For the full copyright and license information, please view the LICENSE
09 * 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\Compiler\ServiceLocatorTagPass;
16 use Symfony\Component\DependencyInjection\ContainerBuilder;
17 use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
18 use Symfony\Component\DependencyInjection\Reference;
19 use Symfony\Component\HttpKernel\Fragment\FragmentRendererInterface;
20
21 /**
22 * Adds services tagged kernel.fragment_renderer as HTTP content rendering strategies.
23 *
24 * @author Fabien Potencier <fabien@symfony.com>
25 */
26 class FragmentRendererPass implements CompilerPassInterface
27 {
28 private $handlerService;
29 private $rendererTag;
30
31 /**
32 * @param string $handlerService Service name of the fragment handler in the container
33 * @param string $rendererTag Tag name used for fragments
34 */
35 public function __construct($handlerService = 'fragment.handler', $rendererTag = 'kernel.fragment_renderer')
36 {
37 $this->handlerService = $handlerService;
38 $this->rendererTag = $rendererTag;
39 }
40
41 public function process(ContainerBuilder $container)
42 {
43 if (!$container->hasDefinition($this->handlerService)) {
44 return;
45 }
46
47 $definition = $container->getDefinition($this->handlerService);
48 $renderers = [];
49 foreach ($container->findTaggedServiceIds($this->rendererTag, true) as $id => $tags) {
50 $def = $container->getDefinition($id);
51 $class = $container->getParameterBag()->resolveValue($def->getClass());
52
53 if (!$r = $container->getReflectionClass($class)) {
54 throw new InvalidArgumentException(sprintf('Class "%s" used for service "%s" cannot be found.', $class, $id));
55 }
56 if (!$r->isSubclassOf(FragmentRendererInterface::class)) {
57 throw new InvalidArgumentException(sprintf('Service "%s" must implement interface "%s".', $id, FragmentRendererInterface::class));
58 }
59
60 foreach ($tags as $tag) {
61 $renderers[$tag['alias']] = new Reference($id);
62 }
63 }
64
65 $definition->replaceArgument(0, ServiceLocatorTagPass::register($container, $renderers));
66 }
67 }
68