|
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\Events\EventServiceProvider; |
|
17
|
|
|
use Illuminate\Filesystem\Filesystem; |
|
18
|
|
|
use Illuminate\Foundation\Application as BaseApplication; |
|
19
|
|
|
use Illuminate\Foundation\PackageManifest; |
|
20
|
|
|
use Illuminate\Support\Collection; |
|
21
|
|
|
use Illuminate\Support\Str; |
|
22
|
|
|
use LaravelZero\Framework\Exceptions\ConsoleException; |
|
23
|
|
|
use Symfony\Component\Console\Exception\CommandNotFoundException; |
|
24
|
|
|
|
|
25
|
|
|
class Application extends BaseApplication |
|
26
|
|
|
{ |
|
27
|
|
|
/** |
|
28
|
|
|
* Get the builds path. With, optionally, a path to append to the base path. |
|
29
|
|
|
*/ |
|
30
|
2 |
|
public function buildsPath(string $path = ''): string |
|
31
|
|
|
{ |
|
32
|
2 |
|
return $this->basePath('builds'.($path ? DIRECTORY_SEPARATOR.$path : $path)); |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* {@inheritdoc} |
|
37
|
|
|
*/ |
|
38
|
39 |
|
protected function registerBaseBindings(): void |
|
39
|
|
|
{ |
|
40
|
39 |
|
parent::registerBaseBindings(); |
|
41
|
|
|
|
|
42
|
|
|
/* |
|
43
|
|
|
* Ignores auto-discovery. |
|
44
|
|
|
*/ |
|
45
|
39 |
|
$this->make(PackageManifest::class)->manifest = []; |
|
46
|
39 |
|
} |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* {@inheritdoc} |
|
50
|
|
|
*/ |
|
51
|
39 |
|
protected function registerBaseServiceProviders(): void |
|
52
|
|
|
{ |
|
53
|
39 |
|
$this->register(new EventServiceProvider($this)); |
|
54
|
39 |
|
} |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* {@inheritdoc} |
|
58
|
|
|
*/ |
|
59
|
39 |
|
public function version() |
|
60
|
|
|
{ |
|
61
|
39 |
|
return $this['config']->get('app.version'); |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
/** |
|
65
|
|
|
* {@inheritdoc} |
|
66
|
|
|
*/ |
|
67
|
39 |
|
public function runningInConsole(): bool |
|
68
|
|
|
{ |
|
69
|
39 |
|
return true; |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* {@inheritdoc} |
|
74
|
|
|
*/ |
|
75
|
1 |
|
public function isDownForMaintenance(): bool |
|
76
|
|
|
{ |
|
77
|
1 |
|
return false; |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
/** |
|
81
|
|
|
* {@inheritdoc} |
|
82
|
|
|
*/ |
|
83
|
39 |
|
public function configurationIsCached(): bool |
|
84
|
|
|
{ |
|
85
|
39 |
|
return false; |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
/** |
|
89
|
|
|
* Register all of the configured providers. |
|
90
|
|
|
*/ |
|
91
|
39 |
|
public function registerConfiguredProviders(): void |
|
92
|
|
|
{ |
|
93
|
39 |
|
$providers = Collection::make($this['config']['app.providers']) |
|
94
|
39 |
|
->partition( |
|
95
|
|
|
function ($provider) { |
|
96
|
39 |
|
return Str::startsWith($provider, 'Illuminate\\'); |
|
97
|
39 |
|
} |
|
98
|
|
|
); |
|
99
|
|
|
|
|
100
|
39 |
|
$providers->splice( |
|
101
|
39 |
|
1, |
|
102
|
39 |
|
0, |
|
103
|
|
|
[ |
|
104
|
39 |
|
$this->make(PackageManifest::class) |
|
105
|
39 |
|
->providers(), |
|
106
|
|
|
] |
|
107
|
|
|
); |
|
108
|
|
|
|
|
109
|
39 |
|
(new ProviderRepository($this, new Filesystem, $this->getCachedServicesPath()))->load( |
|
110
|
39 |
|
$providers->collapse() |
|
111
|
39 |
|
->toArray() |
|
112
|
|
|
); |
|
113
|
39 |
|
} |
|
114
|
|
|
|
|
115
|
|
|
/** |
|
116
|
|
|
* Throw an Console Exception with the given data unless the given condition is true. |
|
117
|
|
|
*/ |
|
118
|
1 |
|
public function abort($code, $message = '', array $headers = []): void |
|
119
|
|
|
{ |
|
120
|
1 |
|
if ($code === 404) { |
|
121
|
1 |
|
throw new CommandNotFoundException($message); |
|
122
|
|
|
} |
|
123
|
|
|
|
|
124
|
1 |
|
throw new ConsoleException($code, $message, $headers); |
|
125
|
|
|
} |
|
126
|
|
|
} |
|
127
|
|
|
|