76e7829e8fe9925fc359ab53c0727f5404238939
[yaffs-website] / vendor / symfony / dependency-injection / Loader / Configurator / PrototypeConfigurator.php
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\DependencyInjection\Loader\Configurator;
13
14 use Symfony\Component\DependencyInjection\Definition;
15 use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;
16
17 /**
18  * @author Nicolas Grekas <p@tchwork.com>
19  */
20 class PrototypeConfigurator extends AbstractServiceConfigurator
21 {
22     const FACTORY = 'load';
23
24     use Traits\AbstractTrait;
25     use Traits\ArgumentTrait;
26     use Traits\AutoconfigureTrait;
27     use Traits\AutowireTrait;
28     use Traits\BindTrait;
29     use Traits\CallTrait;
30     use Traits\ConfiguratorTrait;
31     use Traits\DeprecateTrait;
32     use Traits\FactoryTrait;
33     use Traits\LazyTrait;
34     use Traits\ParentTrait;
35     use Traits\PropertyTrait;
36     use Traits\PublicTrait;
37     use Traits\ShareTrait;
38     use Traits\TagTrait;
39
40     private $loader;
41     private $resource;
42     private $exclude;
43     private $allowParent;
44
45     public function __construct(ServicesConfigurator $parent, PhpFileLoader $loader, Definition $defaults, $namespace, $resource, $allowParent)
46     {
47         $definition = new Definition();
48         $definition->setPublic($defaults->isPublic());
49         $definition->setAutowired($defaults->isAutowired());
50         $definition->setAutoconfigured($defaults->isAutoconfigured());
51         $definition->setBindings($defaults->getBindings());
52         $definition->setChanges(array());
53
54         $this->loader = $loader;
55         $this->resource = $resource;
56         $this->allowParent = $allowParent;
57
58         parent::__construct($parent, $definition, $namespace, $defaults->getTags());
59     }
60
61     public function __destruct()
62     {
63         parent::__destruct();
64
65         if ($this->loader) {
66             $this->loader->registerClasses($this->definition, $this->id, $this->resource, $this->exclude);
67         }
68         $this->loader = null;
69     }
70
71     /**
72      * Excludes files from registration using a glob pattern.
73      *
74      * @param string $exclude
75      *
76      * @return $this
77      */
78     final public function exclude($exclude)
79     {
80         $this->exclude = $exclude;
81
82         return $this;
83     }
84 }