Completed
Branch FET/11183/improvements-to-pue-... (232f50)
by
unknown
43:46 queued 26:36
created

BootstrapDependencyInjectionContainer   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 98
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 98
rs 10
wmc 6
lcom 1
cbo 3

6 Methods

Rating   Name   Duplication   Size   Complexity  
A buildDependencyInjectionContainer() 0 7 1
A buildLegacyDependencyInjectionContainer() 0 15 1
A buildLoader() 0 5 1
A getDependencyMap() 0 4 1
A getRegistry() 0 4 1
A getLoader() 0 4 1
1
<?php
2
3
namespace EventEspresso\core\services\bootstrap;
4
5
use EE_Dependency_Map;
6
use EE_Error;
7
use EE_Registry;
8
use EventEspresso\core\exceptions\InvalidDataTypeException;
9
use EventEspresso\core\exceptions\InvalidInterfaceException;
10
use EventEspresso\core\services\loaders\LoaderFactory;
11
use EventEspresso\core\services\loaders\LoaderInterface;
12
use InvalidArgumentException;
13
14
defined('EVENT_ESPRESSO_VERSION') || exit;
15
16
17
18
/**
19
 * Class BootstrapDependencyInjectionContainer
20
 * Builds the main DI container
21
 *
22
 * @package EventEspresso\core\services\request
23
 * @author  Brent Christensen
24
 * @since   $VID:$
25
 */
26
class BootstrapDependencyInjectionContainer
27
{
28
29
    /**
30
     * @var EE_Dependency_Map $dependency_map
31
     */
32
    protected $dependency_map;
33
34
    /**
35
     * @type LoaderInterface $loader
36
     */
37
    protected $loader;
38
39
    /**
40
     * @var EE_Registry $registry
41
     */
42
    protected $registry;
43
44
45
    /**
46
     * Can't use this just yet until we exorcise some more of our singleton usage from core
47
     */
48
    public function buildDependencyInjectionContainer()
49
    {
50
        // build DI container
51
        // $OpenCoffeeShop = new EventEspresso\core\services\container\OpenCoffeeShop();
52
        // $OpenCoffeeShop->addRecipes();
53
        // $CoffeeShop = $OpenCoffeeShop->CoffeeShop();
54
    }
55
56
57
    /**
58
     * Setups  EE_Registry and EE_Dependency_Map
59
     *
60
     * @throws EE_Error
61
     * @throws InvalidDataTypeException
62
     * @throws InvalidInterfaceException
63
     * @throws InvalidArgumentException
64
     */
65
    public function buildLegacyDependencyInjectionContainer()
66
    {
67
        // EE_Dependency_Map: info about how to load classes required by other classes
68
        espresso_load_required(
69
            'EE_Dependency_Map',
70
            EE_CORE . 'EE_Dependency_Map.core.php'
71
        );
72
        $this->dependency_map = EE_Dependency_Map::instance();
73
        // EE_Registry: central repository for classes (legacy)
74
        espresso_load_required(
75
            'EE_Registry',
76
            EE_CORE . 'EE_Registry.core.php'
77
        );
78
        $this->registry = EE_Registry::instance($this->dependency_map);
79
    }
80
81
82
    /**
83
     * Performs initial setup for the generic Loader
84
     *
85
     * @throws InvalidDataTypeException
86
     * @throws InvalidInterfaceException
87
     * @throws InvalidArgumentException
88
     */
89
    public function buildLoader()
90
    {
91
        $this->loader = LoaderFactory::getLoader($this->registry);
92
        $this->dependency_map->setLoader($this->loader);
93
    }
94
95
96
    /**
97
     * @return EE_Dependency_Map
98
     */
99
    public function getDependencyMap()
100
    {
101
        return $this->dependency_map;
102
    }
103
104
105
    /**
106
     * @return EE_Registry
107
     */
108
    public function getRegistry()
109
    {
110
        return $this->registry;
111
    }
112
113
114
115
    /**
116
     * @return LoaderInterface
117
     */
118
    public function getLoader()
119
    {
120
        return $this->loader;
121
    }
122
123
}
124