forked from slimkit/plus
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApplication.php
More file actions
128 lines (114 loc) · 3.33 KB
/
Copy pathApplication.php
File metadata and controls
128 lines (114 loc) · 3.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
<?php
namespace Zhiyi\Plus;
use Illuminate\Filesystem\Filesystem;
use Illuminate\Foundation\ProviderRepository;
use Illuminate\Foundation\Application as LaravelApplication;
class Application extends LaravelApplication
{
protected $vendorYamlFile;
/**
* Create a new Illuminate application instance.
*
* @param string|null $basePath
* @author Seven Du <shiweidu@outlook.com>
*/
public function __construct($basePath = null)
{
parent::__construct($basePath);
// Load configuration after.
$this->afterBootstrapping(\Illuminate\Foundation\Bootstrap\LoadConfiguration::class, function ($app) {
$app->make(\Zhiyi\Plus\Bootstrap\LoadConfiguration::class)
->handle();
});
}
/**
* Set load vendor environment yaml file to be loaded during bootstrapping.
*
* @param string $file
* @return $this
* @author Seven Du <shiweidu@outlook.com>
*/
public function loadVendorYamlFrom(string $file): self
{
$this->vendorYamlFile = $file;
}
/**
* Get the environment yaml file the application using.
*
* @return string
* @author Seven Du <shiweidu@outlook.com>
*/
public function vendorYamlFile(): string
{
return $this->vendorYamlFile ?: '.plus.yml';
}
/**
* Get the fully qualified path to the environment yaml file.
*
* @return string
* @author Seven Du <shiweidu@outlook.com>
*/
public function vendorYamlFilePath(): string
{
return $this->environmentPath().DIRECTORY_SEPARATOR.$this->vendorYamlFile();
}
/**
* Register all of the configured providers.
*
* @return void
* @author Seven Du <shiweidu@outlook.com>
*/
public function registerConfiguredProviders()
{
(new ProviderRepository($this, new Filesystem, $this->getCachedServicesPath()))
->load($this->getConfiguredProviders());
}
/**
* Register the core class aliases in the container.
*
* @return void
* @author Seven Du <shiweidu@outlook.com>
*/
public function registerCoreContainerAliases()
{
parent::registerCoreContainerAliases();
// Register class aliases.
$this->alias('app', \Zhiyi\Plus\Application::class);
}
/**
* Get the path to the cached packages.php file.
*
* @return string
*/
public function getCachedPackagesPath()
{
return $this->bootstrapPath('cache/packages.php');
}
/**
* Get all of the configured providers.
*
* @return array
* @author Seven Du <shiweidu@outlook.com>
*/
protected function getConfiguredProviders(): array
{
return array_merge(
$this->config['providers'] ?? [], // 内部转换完成后废弃。
$this->make(PackageManifest::class)->providers(),
$this->config['app.providers']
);
}
/**
* Register the basic bindings into the container.
*
* @return void
* @author Seven Du <shiweidu@outlook.com>
*/
protected function registerBaseBindings()
{
parent::registerBaseBindings();
$this->instance(PackageManifest::class, new PackageManifest(
new Filesystem, $this->basePath(), $this->getCachedPackagesPath()
));
}
}