1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* This file is part of Laravel Zero. |
7
|
|
|
* |
8
|
|
|
* (c) Nuno Maduro <[email protected]> |
9
|
|
|
* |
10
|
|
|
* For the full copyright and license information, please view the LICENSE |
11
|
|
|
* file that was distributed with this source code. |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
namespace LaravelZero\Framework; |
15
|
|
|
|
16
|
|
|
use Illuminate\Support\Str; |
17
|
|
|
use Illuminate\Support\Collection; |
18
|
|
|
use Illuminate\Filesystem\Filesystem; |
19
|
|
|
use Illuminate\Foundation\PackageManifest; |
20
|
|
|
use Illuminate\Events\EventServiceProvider; |
21
|
|
|
use LaravelZero\Framework\Exceptions\ConsoleException; |
22
|
|
|
use Illuminate\Foundation\Application as BaseApplication; |
23
|
|
|
use Symfony\Component\Console\Exception\CommandNotFoundException; |
24
|
|
|
|
25
|
|
|
class Application extends BaseApplication |
26
|
|
|
{ |
27
|
|
|
/** |
28
|
|
|
* Get the builds path. |
29
|
|
|
* |
30
|
|
|
* @param string $path Optionally, a path to append to the base path |
31
|
|
|
* |
32
|
|
|
* @return string |
33
|
|
|
*/ |
34
|
2 |
|
public function buildsPath(string $path = ''): string |
35
|
|
|
{ |
36
|
2 |
|
return $this->basePath('builds' . ($path ? DIRECTORY_SEPARATOR . $path : $path)); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* {@inheritdoc} |
41
|
|
|
*/ |
42
|
22 |
|
protected function registerBaseBindings(): void |
43
|
|
|
{ |
44
|
22 |
|
parent::registerBaseBindings(); |
45
|
|
|
|
46
|
|
|
/* |
47
|
|
|
* Ignores auto-discovery. |
48
|
|
|
*/ |
49
|
22 |
|
$this->make(PackageManifest::class)->manifest = []; |
50
|
22 |
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* {@inheritdoc} |
54
|
|
|
*/ |
55
|
22 |
|
protected function registerBaseServiceProviders(): void |
56
|
|
|
{ |
57
|
22 |
|
$this->register(new EventServiceProvider($this)); |
58
|
22 |
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* {@inheritdoc} |
62
|
|
|
*/ |
63
|
22 |
|
public function version() |
64
|
|
|
{ |
65
|
22 |
|
return $this['config']->get('app.version'); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* {@inheritdoc} |
70
|
|
|
*/ |
71
|
22 |
|
public function runningInConsole(): bool |
72
|
|
|
{ |
73
|
22 |
|
return true; |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* {@inheritdoc} |
78
|
|
|
*/ |
79
|
1 |
|
public function isDownForMaintenance(): bool |
80
|
|
|
{ |
81
|
1 |
|
return false; |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* {@inheritdoc} |
86
|
|
|
*/ |
87
|
22 |
|
public function configurationIsCached(): bool |
88
|
|
|
{ |
89
|
22 |
|
return false; |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* Register all of the configured providers. |
94
|
|
|
* |
95
|
|
|
* @return void |
96
|
|
|
*/ |
97
|
22 |
|
public function registerConfiguredProviders(): void |
98
|
|
|
{ |
99
|
22 |
|
$providers = Collection::make($this['config']['app.providers']) |
100
|
22 |
|
->partition( |
101
|
|
|
function ($provider) { |
102
|
22 |
|
return Str::startsWith($provider, 'Illuminate\\'); |
103
|
22 |
|
} |
104
|
|
|
); |
105
|
|
|
|
106
|
22 |
|
$providers->splice( |
107
|
22 |
|
1, |
108
|
22 |
|
0, |
109
|
|
|
[ |
110
|
22 |
|
$this->make(PackageManifest::class) |
111
|
22 |
|
->providers(), |
112
|
|
|
] |
113
|
|
|
); |
114
|
|
|
|
115
|
22 |
|
(new ProviderRepository($this, new Filesystem, $this->getCachedServicesPath()))->load( |
116
|
22 |
|
$providers->collapse() |
117
|
22 |
|
->toArray() |
118
|
|
|
); |
119
|
22 |
|
} |
120
|
|
|
|
121
|
|
|
/** |
122
|
|
|
* Throw an Console Exception with the given data unless the given condition is true. |
123
|
|
|
* |
124
|
|
|
* @param int $code |
125
|
|
|
* @param string $message |
126
|
|
|
* @param array $headers |
127
|
|
|
* @return void |
128
|
|
|
* |
129
|
|
|
* @throws \Symfony\Component\Console\Exception\CommandNotFoundException |
130
|
|
|
* @throws \LaravelZero\Framework\Contracts\Exceptions\ConsoleExceptionContract |
131
|
|
|
*/ |
132
|
1 |
|
public function abort($code, $message = '', array $headers = []): void |
133
|
|
|
{ |
134
|
1 |
|
if ($code === 404) { |
135
|
1 |
|
throw new CommandNotFoundException($message); |
136
|
|
|
} |
137
|
|
|
|
138
|
1 |
|
throw new ConsoleException($code, $message, $headers); |
139
|
|
|
} |
140
|
|
|
} |
141
|
|
|
|