/
LivewireServiceProvider.php
129 lines (110 loc) · 4.9 KB
/
LivewireServiceProvider.php
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
<?php
namespace Livewire;
use Composer\InstalledVersions;
use Illuminate\Foundation\Console\AboutCommand;
class LivewireServiceProvider extends \Illuminate\Support\ServiceProvider
{
public function register()
{
$this->registerLivewireSingleton();
$this->registerConfig();
$this->bootEventBus();
$this->registerMechanisms();
}
public function boot()
{
$this->bootMechanisms();
$this->bootFeatures();
}
protected function registerLivewireSingleton()
{
$this->app->alias(LivewireManager::class, 'livewire');
$this->app->singleton(LivewireManager::class);
app('livewire')->setProvider($this);
}
protected function registerConfig()
{
$config = __DIR__.'/../config/livewire.php';
$this->publishes([$config => base_path('config/livewire.php')], ['livewire', 'livewire:config']);
$this->mergeConfigFrom($config, 'livewire');
}
protected function bootEventBus()
{
app(EventBus::class)->boot();
}
protected function getMechanisms()
{
return [
Mechanisms\PersistentMiddleware\PersistentMiddleware::class,
Mechanisms\HandleComponents\HandleComponents::class,
Mechanisms\HandleRequests\HandleRequests::class,
Mechanisms\FrontendAssets\FrontendAssets::class,
Mechanisms\ExtendBlade\ExtendBlade::class,
Mechanisms\CompileLivewireTags\CompileLivewireTags::class,
Mechanisms\ComponentRegistry::class,
Mechanisms\RenderComponent::class,
Mechanisms\DataStore::class,
];
}
protected function registerMechanisms()
{
foreach ($this->getMechanisms() as $mechanism) {
app($mechanism)->register();
}
}
protected function bootMechanisms()
{
if (class_exists(AboutCommand::class) && class_exists(InstalledVersions::class)) {
AboutCommand::add('Livewire', [
'Livewire' => InstalledVersions::getPrettyVersion('livewire/livewire'),
]);
}
foreach ($this->getMechanisms() as $mechanism) {
app($mechanism)->boot();
}
}
protected function bootFeatures()
{
foreach([
Features\SupportWireModelingNestedComponents\SupportWireModelingNestedComponents::class,
Features\SupportMultipleRootElementDetection\SupportMultipleRootElementDetection::class,
Features\SupportDisablingBackButtonCache\SupportDisablingBackButtonCache::class,
Features\SupportNestedComponentListeners\SupportNestedComponentListeners::class,
Features\SupportMorphAwareIfStatement\SupportMorphAwareIfStatement::class,
Features\SupportAutoInjectedAssets\SupportAutoInjectedAssets::class,
Features\SupportComputed\SupportLegacyComputedPropertySyntax::class,
Features\SupportNestingComponents\SupportNestingComponents::class,
Features\SupportScriptsAndAssets\SupportScriptsAndAssets::class,
Features\SupportBladeAttributes\SupportBladeAttributes::class,
Features\SupportConsoleCommands\SupportConsoleCommands::class,
Features\SupportPageComponents\SupportPageComponents::class,
Features\SupportReactiveProps\SupportReactiveProps::class,
Features\SupportFileDownloads\SupportFileDownloads::class,
Features\SupportJsEvaluation\SupportJsEvaluation::class,
Features\SupportQueryString\SupportQueryString::class,
Features\SupportFileUploads\SupportFileUploads::class,
Features\SupportTeleporting\SupportTeleporting::class,
Features\SupportLazyLoading\SupportLazyLoading::class,
Features\SupportFormObjects\SupportFormObjects::class,
Features\SupportAttributes\SupportAttributes::class,
Features\SupportPagination\SupportPagination::class,
Features\SupportValidation\SupportValidation::class,
Features\SupportIsolating\SupportIsolating::class,
Features\SupportRedirects\SupportRedirects::class,
Features\SupportStreaming\SupportStreaming::class,
Features\SupportNavigate\SupportNavigate::class,
Features\SupportEntangle\SupportEntangle::class,
Features\SupportLocales\SupportLocales::class,
Features\SupportTesting\SupportTesting::class,
Features\SupportModels\SupportModels::class,
Features\SupportEvents\SupportEvents::class,
// Some features we want to have priority over others...
Features\SupportLifecycleHooks\SupportLifecycleHooks::class,
Features\SupportLegacyModels\SupportLegacyModels::class,
Features\SupportWireables\SupportWireables::class,
] as $feature) {
app('livewire')->componentHook($feature);
}
ComponentHookRegistry::boot();
}
}