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 |
ServicesConfigurator.php
001 <?php
002
003 /*
004 * This file is part of the Symfony package.
005 *
006 * (c) Fabien Potencier <fabien@symfony.com>
007 *
008 * For the full copyright and license information, please view the LICENSE
009 * file that was distributed with this source code.
010 */
011
012 namespace Symfony\Component\DependencyInjection\Loader\Configurator;
013
014 use Symfony\Component\DependencyInjection\Alias;
015 use Symfony\Component\DependencyInjection\ChildDefinition;
016 use Symfony\Component\DependencyInjection\ContainerBuilder;
017 use Symfony\Component\DependencyInjection\Definition;
018 use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException;
019 use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;
020
021 /**
022 * @author Nicolas Grekas <p@tchwork.com>
023 *
024 * @method InstanceofConfigurator instanceof($fqcn)
025 */
026 class ServicesConfigurator extends AbstractConfigurator
027 {
028 const FACTORY = 'services';
029
030 private $defaults;
031 private $container;
032 private $loader;
033 private $instanceof;
034
035 public function __construct(ContainerBuilder $container, PhpFileLoader $loader, array &$instanceof)
036 {
037 $this->defaults = new Definition();
038 $this->container = $container;
039 $this->loader = $loader;
040 $this->instanceof = &$instanceof;
041 $instanceof = [];
042 }
043
044 /**
045 * Defines a set of defaults for following service definitions.
046 *
047 * @return DefaultsConfigurator
048 */
049 final public function defaults()
050 {
051 return new DefaultsConfigurator($this, $this->defaults = new Definition());
052 }
053
054 /**
055 * Defines an instanceof-conditional to be applied to following service definitions.
056 *
057 * @param string $fqcn
058 *
059 * @return InstanceofConfigurator
060 */
061 final protected function setInstanceof($fqcn)
062 {
063 $this->instanceof[$fqcn] = $definition = new ChildDefinition('');
064
065 return new InstanceofConfigurator($this, $definition, $fqcn);
066 }
067
068 /**
069 * Registers a service.
070 *
071 * @param string $id
072 * @param string|null $class
073 *
074 * @return ServiceConfigurator
075 */
076 final public function set($id, $class = null)
077 {
078 $defaults = $this->defaults;
079 $allowParent = !$defaults->getChanges() && empty($this->instanceof);
080
081 $definition = new Definition();
082 if (!$defaults->isPublic() || !$defaults->isPrivate()) {
083 $definition->setPublic($defaults->isPublic() && !$defaults->isPrivate());
084 }
085 $definition->setAutowired($defaults->isAutowired());
086 $definition->setAutoconfigured($defaults->isAutoconfigured());
087 // deep clone, to avoid multiple process of the same instance in the passes
088 $definition->setBindings(unserialize(serialize($defaults->getBindings())));
089 $definition->setChanges([]);
090
091 $configurator = new ServiceConfigurator($this->container, $this->instanceof, $allowParent, $this, $definition, $id, $defaults->getTags());
092
093 return null !== $class ? $configurator->class($class) : $configurator;
094 }
095
096 /**
097 * Creates an alias.
098 *
099 * @param string $id
100 * @param string $referencedId
101 *
102 * @return AliasConfigurator
103 */
104 final public function alias($id, $referencedId)
105 {
106 $ref = static::processValue($referencedId, true);
107 $alias = new Alias((string) $ref);
108 if (!$this->defaults->isPublic() || !$this->defaults->isPrivate()) {
109 $alias->setPublic($this->defaults->isPublic());
110 }
111 $this->container->setAlias($id, $alias);
112
113 return new AliasConfigurator($this, $alias);
114 }
115
116 /**
117 * Registers a PSR-4 namespace using a glob pattern.
118 *
119 * @param string $namespace
120 * @param string $resource
121 *
122 * @return PrototypeConfigurator
123 */
124 final public function load($namespace, $resource)
125 {
126 $allowParent = !$this->defaults->getChanges() && empty($this->instanceof);
127
128 return new PrototypeConfigurator($this, $this->loader, $this->defaults, $namespace, $resource, $allowParent);
129 }
130
131 /**
132 * Gets an already defined service definition.
133 *
134 * @param string $id
135 *
136 * @return ServiceConfigurator
137 *
138 * @throws ServiceNotFoundException if the service definition does not exist
139 */
140 final public function get($id)
141 {
142 $allowParent = !$this->defaults->getChanges() && empty($this->instanceof);
143 $definition = $this->container->getDefinition($id);
144
145 return new ServiceConfigurator($this->container, $definition->getInstanceofConditionals(), $allowParent, $this, $definition, $id, []);
146 }
147
148 /**
149 * Registers a service.
150 *
151 * @param string $id
152 * @param string|null $class
153 *
154 * @return ServiceConfigurator
155 */
156 final public function __invoke($id, $class = null)
157 {
158 return $this->set($id, $class);
159 }
160 }
161