1 | <?php |
||
29 | class BootstrapDependencyInjectionContainer |
||
30 | { |
||
31 | |||
32 | /** |
||
33 | * @var EE_Dependency_Map $dependency_map |
||
34 | */ |
||
35 | protected $dependency_map; |
||
36 | |||
37 | /** |
||
38 | * @type LoaderInterface $loader |
||
39 | */ |
||
40 | protected $loader; |
||
41 | |||
42 | /** |
||
43 | * @var EE_Registry $registry |
||
44 | */ |
||
45 | protected $registry; |
||
46 | |||
47 | /** |
||
48 | * @var ClassInterfaceCache $class_cache |
||
49 | */ |
||
50 | private $class_cache; |
||
51 | |||
52 | /** |
||
53 | * @var Mirror |
||
54 | */ |
||
55 | private $mirror; |
||
56 | |||
57 | /** |
||
58 | * @var ObjectIdentifier |
||
59 | */ |
||
60 | private $object_identifier; |
||
61 | |||
62 | |||
63 | /** |
||
64 | * Can't use this just yet until we exorcise some more of our singleton usage from core |
||
65 | */ |
||
66 | public function buildDependencyInjectionContainer() |
||
73 | |||
74 | |||
75 | /** |
||
76 | * Setups EE_Registry and EE_Dependency_Map |
||
77 | * |
||
78 | * @throws EE_Error |
||
79 | */ |
||
80 | public function buildLegacyDependencyInjectionContainer() |
||
81 | { |
||
82 | $this->class_cache = new ClassInterfaceCache(); |
||
83 | $this->object_identifier = new ObjectIdentifier($this->class_cache); |
||
84 | $this->mirror = new Mirror(); |
||
85 | // EE_Dependency_Map: info about how to load classes required by other classes |
||
86 | espresso_load_required( |
||
87 | 'EE_Dependency_Map', |
||
88 | EE_CORE . 'EE_Dependency_Map.core.php' |
||
89 | ); |
||
90 | $this->dependency_map = EE_Dependency_Map::instance($this->class_cache); |
||
91 | // EE_Registry: central repository for classes (legacy) |
||
92 | espresso_load_required( |
||
93 | 'EE_Registry', |
||
94 | EE_CORE . 'EE_Registry.core.php' |
||
95 | ); |
||
96 | $this->registry = EE_Registry::instance( |
||
97 | $this->dependency_map, |
||
98 | $this->mirror, |
||
99 | $this->class_cache, |
||
100 | $this->object_identifier |
||
101 | ); |
||
102 | |||
103 | } |
||
104 | |||
105 | |||
106 | /** |
||
107 | * Performs initial setup for the generic Loader |
||
108 | * |
||
109 | * @throws InvalidDataTypeException |
||
110 | * @throws InvalidInterfaceException |
||
111 | * @throws InvalidArgumentException |
||
112 | */ |
||
113 | public function buildLoader() |
||
114 | { |
||
115 | $this->loader = LoaderFactory::getLoader( |
||
116 | $this->registry, |
||
117 | $this->class_cache, |
||
118 | $this->object_identifier |
||
119 | ); |
||
120 | $this->loader->share('EventEspresso\core\services\loaders\ClassInterfaceCache', $this->class_cache); |
||
121 | $this->loader->share('EventEspresso\core\services\loaders\ObjectIdentifier', $this->object_identifier); |
||
122 | $this->loader->share('EventEspresso\core\services\container\Mirror', $this->mirror); |
||
123 | $this->dependency_map->setLoader($this->loader); |
||
124 | } |
||
125 | |||
126 | |||
127 | /** |
||
128 | * @return EE_Dependency_Map |
||
129 | */ |
||
130 | public function getDependencyMap() |
||
134 | |||
135 | |||
136 | /** |
||
137 | * @return EE_Registry |
||
138 | */ |
||
139 | public function getRegistry() |
||
143 | |||
144 | |||
145 | |||
146 | /** |
||
147 | * @return LoaderInterface |
||
148 | */ |
||
149 | public function getLoader() |
||
153 | |||
154 | } |
||
155 |