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

(Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

DecoratorServicePass.php

Zuletzt modifiziert: 02.04.2025, 15:03 - Dateigröße: 3.07 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\DependencyInjection\Compiler;
13   
14  use Symfony\Component\DependencyInjection\Alias;
15  use Symfony\Component\DependencyInjection\ContainerBuilder;
16   
17  /**
18   * Overwrites a service but keeps the overridden one.
19   *
20   * @author Christophe Coevoet <stof@notk.org>
21   * @author Fabien Potencier <fabien@symfony.com>
22   * @author Diego Saint Esteben <diego@saintesteben.me>
23   */
24  class DecoratorServicePass implements CompilerPassInterface
25  {
26      public function process(ContainerBuilder $container)
27      {
28          $definitions = new \SplPriorityQueue();
29          $order = \PHP_INT_MAX;
30   
31          foreach ($container->getDefinitions() as $id => $definition) {
32              if (!$decorated = $definition->getDecoratedService()) {
33                  continue;
34              }
35              $definitions->insert([$id, $definition], [$decorated[2], --$order]);
36          }
37          $decoratingDefinitions = [];
38   
39          foreach ($definitions as list($id, $definition)) {
40              list($inner, $renamedId) = $definition->getDecoratedService();
41   
42              $definition->setDecoratedService(null);
43   
44              if (!$renamedId) {
45                  $renamedId = $id.'.inner';
46              }
47   
48              // we create a new alias/service for the service we are replacing
49              // to be able to reference it in the new one
50              if ($container->hasAlias($inner)) {
51                  $alias = $container->getAlias($inner);
52                  $public = $alias->isPublic();
53                  $private = $alias->isPrivate();
54                  $container->setAlias($renamedId, new Alias($container->normalizeId($alias), false));
55              } else {
56                  $decoratedDefinition = $container->getDefinition($inner);
57                  $public = $decoratedDefinition->isPublic();
58                  $private = $decoratedDefinition->isPrivate();
59                  $decoratedDefinition->setPublic(false);
60                  $container->setDefinition($renamedId, $decoratedDefinition);
61                  $decoratingDefinitions[$inner] = $decoratedDefinition;
62              }
63   
64              if (isset($decoratingDefinitions[$inner])) {
65                  $decoratingDefinition = $decoratingDefinitions[$inner];
66                  $definition->setTags(array_merge($decoratingDefinition->getTags(), $definition->getTags()));
67                  $autowiringTypes = $decoratingDefinition->getAutowiringTypes(false);
68                  if ($types = array_merge($autowiringTypes, $definition->getAutowiringTypes(false))) {
69                      $definition->setAutowiringTypes($types);
70                  }
71                  $decoratingDefinition->setTags([]);
72                  if ($autowiringTypes) {
73                      $decoratingDefinition->setAutowiringTypes([]);
74                  }
75                  $decoratingDefinitions[$inner] = $definition;
76              }
77   
78              $container->setAlias($inner, $id)->setPublic($public)->setPrivate($private);
79          }
80      }
81  }
82