1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace LaravelZero\Framework; |
4
|
|
|
|
5
|
|
|
use Illuminate\Container\Container as BaseContainer; |
6
|
|
|
use LaravelZero\Framework\Exceptions\NotImplementedException; |
7
|
|
|
use Illuminate\Contracts\Foundation\Application as LaravelApplication; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* This is the Laravel Zero Framework container class. |
11
|
|
|
* |
12
|
|
|
* @author Nuno Maduro <[email protected]> |
13
|
|
|
*/ |
14
|
|
|
class Container extends BaseContainer implements LaravelApplication |
15
|
|
|
{ |
16
|
|
|
/** |
17
|
|
|
* A custom callback used to configure Monolog. |
18
|
|
|
* |
19
|
|
|
* @var callable|null |
20
|
|
|
*/ |
21
|
|
|
protected $monologConfigurator; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* {@inheritdoc} |
25
|
|
|
*/ |
26
|
|
|
public function version() |
27
|
|
|
{ |
28
|
|
|
return config('app.version'); |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Get the base path of the Laravel installation. |
33
|
|
|
* |
34
|
|
|
* @param string $path |
35
|
|
|
* |
36
|
|
|
* @return string |
37
|
|
|
*/ |
38
|
|
|
public function basePath($path = '') |
39
|
|
|
{ |
40
|
|
|
return BASE_PATH.($path ? DIRECTORY_SEPARATOR.$path : $path); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* Get the path to the application configuration files. |
45
|
|
|
* |
46
|
|
|
* @param string $path |
47
|
|
|
* |
48
|
|
|
* @return string |
49
|
|
|
*/ |
50
|
|
|
public function configPath($path = '') |
51
|
|
|
{ |
52
|
|
|
return BASE_PATH.DIRECTORY_SEPARATOR.'config'.($path ? DIRECTORY_SEPARATOR.$path : $path); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* Get the path to the database directory. |
57
|
|
|
* |
58
|
|
|
* @param string $path |
59
|
|
|
* |
60
|
|
|
* @return string |
61
|
|
|
*/ |
62
|
|
|
public function databasePath($path = '') |
63
|
|
|
{ |
64
|
|
|
return (BASE_PATH.DIRECTORY_SEPARATOR.'database').($path ? DIRECTORY_SEPARATOR.$path : $path); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* Get the path to the language files. |
69
|
|
|
* |
70
|
|
|
* @return string |
71
|
|
|
*/ |
72
|
|
|
public function langPath() |
73
|
|
|
{ |
74
|
|
|
return $this->resourcePath('lang'); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* Get the path to the resources directory. |
79
|
|
|
* |
80
|
|
|
* @param string $path |
81
|
|
|
* |
82
|
|
|
* @return string |
83
|
|
|
*/ |
84
|
|
|
public function resourcePath($path = '') |
85
|
|
|
{ |
86
|
|
|
return BASE_PATH.DIRECTORY_SEPARATOR.'resources'.($path ? DIRECTORY_SEPARATOR.$path : $path); |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* Get the path to the storage directory. |
91
|
|
|
* |
92
|
|
|
* @return string |
93
|
|
|
*/ |
94
|
|
|
public function storagePath() |
95
|
|
|
{ |
96
|
|
|
return BASE_PATH.DIRECTORY_SEPARATOR.'storage'; |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* {@inheritdoc} |
101
|
|
|
*/ |
102
|
|
|
public function environment() |
103
|
|
|
{ |
104
|
|
|
return config('app.production') ? 'production' : 'development'; |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
/** |
108
|
|
|
* {@inheritdoc} |
109
|
|
|
*/ |
110
|
|
|
public function runningInConsole() |
111
|
|
|
{ |
112
|
|
|
return true; |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
/** |
116
|
|
|
* {@inheritdoc} |
117
|
|
|
*/ |
118
|
|
|
public function getNamespace() |
119
|
|
|
{ |
120
|
|
|
return 'App'; |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
/** |
124
|
|
|
* {@inheritdoc} |
125
|
|
|
*/ |
126
|
|
|
public function isDownForMaintenance() |
127
|
|
|
{ |
128
|
|
|
return false; |
129
|
|
|
} |
130
|
|
|
|
131
|
|
|
/** |
132
|
|
|
* {@inheritdoc} |
133
|
|
|
*/ |
134
|
|
|
public function registerConfiguredProviders() |
135
|
|
|
{ |
136
|
|
|
throw new NotImplementedException; |
137
|
|
|
} |
138
|
|
|
|
139
|
|
|
/** |
140
|
|
|
* {@inheritdoc} |
141
|
|
|
*/ |
142
|
|
|
public function register($provider, $options = [], $force = false) |
143
|
|
|
{ |
144
|
|
|
throw new NotImplementedException; |
145
|
|
|
} |
146
|
|
|
|
147
|
|
|
/** |
148
|
|
|
* {@inheritdoc} |
149
|
|
|
*/ |
150
|
|
|
public function registerDeferredProvider($provider, $service = null) |
151
|
|
|
{ |
152
|
|
|
throw new NotImplementedException; |
153
|
|
|
} |
154
|
|
|
|
155
|
|
|
/** |
156
|
|
|
* {@inheritdoc} |
157
|
|
|
*/ |
158
|
|
|
public function boot() |
159
|
|
|
{ |
160
|
|
|
throw new NotImplementedException; |
161
|
|
|
} |
162
|
|
|
|
163
|
|
|
/** |
164
|
|
|
* {@inheritdoc} |
165
|
|
|
*/ |
166
|
|
|
public function booting($callback) |
167
|
|
|
{ |
168
|
|
|
throw new NotImplementedException; |
169
|
|
|
} |
170
|
|
|
|
171
|
|
|
/** |
172
|
|
|
* {@inheritdoc} |
173
|
|
|
*/ |
174
|
|
|
public function booted($callback) |
175
|
|
|
{ |
176
|
|
|
throw new NotImplementedException; |
177
|
|
|
} |
178
|
|
|
|
179
|
|
|
/** |
180
|
|
|
* {@inheritdoc} |
181
|
|
|
*/ |
182
|
|
|
public function getCachedServicesPath() |
183
|
|
|
{ |
184
|
|
|
throw new NotImplementedException; |
185
|
|
|
} |
186
|
|
|
|
187
|
|
|
/** |
188
|
|
|
* {@inheritdoc} |
189
|
|
|
*/ |
190
|
|
|
public function getCachedPackagesPath() |
191
|
|
|
{ |
192
|
|
|
throw new NotImplementedException; |
193
|
|
|
} |
194
|
|
|
|
195
|
|
|
/** |
196
|
|
|
* Define a callback to be used to configure Monolog. |
197
|
|
|
* |
198
|
|
|
* @param callable $callback |
199
|
|
|
* |
200
|
|
|
* @return $this |
201
|
|
|
*/ |
202
|
|
|
public function configureMonologUsing(callable $callback) |
203
|
|
|
{ |
204
|
|
|
$this->monologConfigurator = $callback; |
205
|
|
|
|
206
|
|
|
return $this; |
207
|
|
|
} |
208
|
|
|
|
209
|
|
|
/** |
210
|
|
|
* Determine if the application has a custom Monolog configurator. |
211
|
|
|
* |
212
|
|
|
* @return bool |
213
|
|
|
*/ |
214
|
|
|
public function hasMonologConfigurator() |
215
|
|
|
{ |
216
|
|
|
return ! is_null($this->monologConfigurator); |
217
|
|
|
} |
218
|
|
|
|
219
|
|
|
/** |
220
|
|
|
* Get the custom Monolog configurator for the application. |
221
|
|
|
* |
222
|
|
|
* @return callable |
223
|
|
|
*/ |
224
|
|
|
public function getMonologConfigurator() |
225
|
|
|
{ |
226
|
|
|
return $this->monologConfigurator; |
227
|
|
|
} |
228
|
|
|
} |
229
|
|
|
|