Verzeichnisstruktur phpBB-3.2.0


Veröffentlicht
06.01.2017

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.
Auf den Verzeichnisnamen klicken, dies zeigt nur das Verzeichnis mit Inhalt an

(Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

FragmentRendererPass.php

Zuletzt modifiziert: 09.10.2024, 12:56 - Dateigröße: 3.00 KiB


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\ContainerBuilder;
15  use Symfony\Component\DependencyInjection\Reference;
16  use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
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  }
79