1 | <?php |
||
23 | class App { |
||
24 | |||
25 | /** |
||
26 | * Flag if Carbon Fields has been booted |
||
27 | * |
||
28 | * @var bool |
||
29 | */ |
||
30 | public $booted = false; |
||
31 | |||
32 | /** |
||
33 | * Inversion of Control container instance |
||
34 | * |
||
35 | * @var PimpleContainer |
||
36 | */ |
||
37 | protected $ioc = null; |
||
38 | |||
39 | /** |
||
40 | * Singleton implementation |
||
41 | * |
||
42 | * @return App |
||
43 | */ |
||
44 | 1 | public static function instance() { |
|
45 | 1 | static $instance = null; |
|
46 | 1 | if ( $instance === null ) { |
|
47 | $instance = new static(); |
||
48 | } |
||
49 | 1 | return $instance; |
|
50 | } |
||
51 | |||
52 | /** |
||
53 | * Get default IoC container dependencies |
||
54 | * |
||
55 | * @return PimpleContainer |
||
56 | */ |
||
57 | protected static function get_default_ioc() { |
||
108 | |||
109 | /** |
||
110 | * Resolve a dependency through IoC |
||
111 | * |
||
112 | * @param string $key |
||
113 | * @return mixed |
||
114 | */ |
||
115 | public static function resolve( $key ) { |
||
118 | |||
119 | /** |
||
120 | * Resolve a service through IoC |
||
121 | * |
||
122 | * @param string $service_name |
||
123 | * @return mixed |
||
124 | */ |
||
125 | public static function service( $service_name ) { |
||
128 | |||
129 | /** |
||
130 | * Replace the ioc container for the App |
||
131 | * |
||
132 | * @param PimpleContainer $ioc |
||
133 | */ |
||
134 | 1 | public function install( PimpleContainer $ioc ) { |
|
135 | 1 | $this->ioc = $ioc; |
|
136 | 1 | } |
|
137 | |||
138 | /** |
||
139 | * Boot Carbon Fields with default IoC dependencies |
||
140 | */ |
||
141 | public static function boot() { |
||
154 | |||
155 | /** |
||
156 | * Check if Carbon Fields has booted |
||
157 | */ |
||
158 | 1 | public static function is_booted() { |
|
161 | |||
162 | /** |
||
163 | * Throw exception if Carbon Fields has not been booted |
||
164 | */ |
||
165 | 1 | public static function verify_boot() { |
|
170 | } |