1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Hyde\Framework; |
4
|
|
|
|
5
|
|
|
use Hyde\Framework\Concerns\RegistersFileLocations; |
6
|
|
|
use Hyde\Framework\Models\Pages\BladePage; |
7
|
|
|
use Hyde\Framework\Models\Pages\DocumentationPage; |
8
|
|
|
use Hyde\Framework\Models\Pages\MarkdownPage; |
9
|
|
|
use Hyde\Framework\Models\Pages\MarkdownPost; |
10
|
|
|
use Hyde\Framework\Services\AssetService; |
11
|
|
|
use Hyde\Framework\Services\YamlConfigurationService; |
12
|
|
|
use Hyde\Framework\Views\Components\LinkComponent; |
13
|
|
|
use Illuminate\Support\Facades\Blade; |
14
|
|
|
use Illuminate\Support\ServiceProvider; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* Register and bootstrap Hyde application services. |
18
|
|
|
*/ |
19
|
|
|
class HydeServiceProvider extends ServiceProvider |
20
|
|
|
{ |
21
|
|
|
use RegistersFileLocations; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* Register any application services. |
25
|
|
|
* |
26
|
|
|
* @return void |
27
|
|
|
*/ |
28
|
|
|
public function register(): void |
29
|
|
|
{ |
30
|
|
|
$this->initializeConfiguration(); |
31
|
|
|
|
32
|
|
|
$this->app->singleton(AssetService::class, AssetService::class); |
33
|
|
|
|
34
|
|
|
$this->registerSourceDirectories([ |
35
|
|
|
BladePage::class => '_pages', |
36
|
|
|
MarkdownPage::class => '_pages', |
37
|
|
|
MarkdownPost::class => '_posts', |
38
|
|
|
DocumentationPage::class => '_docs', |
39
|
|
|
]); |
40
|
|
|
|
41
|
|
|
$this->registerOutputDirectories([ |
42
|
|
|
BladePage::class => '', |
43
|
|
|
MarkdownPage::class => '', |
44
|
|
|
MarkdownPost::class => 'posts', |
45
|
|
|
DocumentationPage::class => unslash(config('docs.output_directory', 'docs')), |
46
|
|
|
]); |
47
|
|
|
|
48
|
|
|
$this->storeCompiledSiteIn(Hyde::path( |
49
|
|
|
unslash(config('site.output_directory', '_site')) |
50
|
|
|
)); |
51
|
|
|
|
52
|
|
|
$this->discoverBladeViewsIn(BladePage::getSourceDirectory()); |
53
|
|
|
|
54
|
|
|
$this->registerHydeConsoleCommands(); |
55
|
|
|
$this->registerModuleServiceProviders(); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* Bootstrap any application services. |
60
|
|
|
* |
61
|
|
|
* @return void |
62
|
|
|
*/ |
63
|
|
|
public function boot(): void |
64
|
|
|
{ |
65
|
|
|
$this->loadViewsFrom(__DIR__.'/../resources/views', 'hyde'); |
66
|
|
|
|
67
|
|
|
$this->publishes([ |
68
|
|
|
__DIR__.'/../config' => config_path(), |
69
|
|
|
], 'configs'); |
70
|
|
|
|
71
|
|
|
$this->publishes([ |
72
|
|
|
__DIR__.'/../resources/views/layouts' => resource_path('views/vendor/hyde/layouts'), |
73
|
|
|
], 'hyde-layouts'); |
74
|
|
|
|
75
|
|
|
$this->publishes([ |
76
|
|
|
__DIR__.'/../resources/views/components' => resource_path('views/vendor/hyde/components'), |
77
|
|
|
], 'hyde-components'); |
78
|
|
|
|
79
|
|
|
$this->publishes([ |
80
|
|
|
Hyde::vendorPath('resources/views/pages/404.blade.php') => Hyde::path('_pages/404.blade.php'), |
81
|
|
|
], 'hyde-page-404'); |
82
|
|
|
|
83
|
|
|
$this->publishes([ |
84
|
|
|
Hyde::vendorPath('resources/views/homepages/welcome.blade.php') => Hyde::path('_pages/index.blade.php'), |
85
|
|
|
], 'hyde-welcome-page'); |
86
|
|
|
|
87
|
|
|
Blade::component('link', LinkComponent::class); |
88
|
|
|
|
89
|
|
|
HydeKernel::getInstance()->boot(); |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
protected function initializeConfiguration() |
93
|
|
|
{ |
94
|
|
|
if (YamlConfigurationService::hasFile()) { |
95
|
|
|
YamlConfigurationService::boot(); |
96
|
|
|
} |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* Register the HydeCLI console commands. |
101
|
|
|
*/ |
102
|
|
|
protected function registerHydeConsoleCommands(): void |
103
|
|
|
{ |
104
|
|
|
$this->commands([ |
105
|
|
|
Commands\HydePublishHomepageCommand::class, |
106
|
|
|
Commands\HydeUpdateConfigsCommand::class, |
107
|
|
|
Commands\HydePublishViewsCommand::class, |
108
|
|
|
Commands\HydeRebuildStaticSiteCommand::class, |
109
|
|
|
Commands\HydeBuildStaticSiteCommand::class, |
110
|
|
|
Commands\HydeBuildSitemapCommand::class, |
111
|
|
|
Commands\HydeBuildRssFeedCommand::class, |
112
|
|
|
Commands\HydeBuildSearchCommand::class, |
113
|
|
|
Commands\HydeMakePostCommand::class, |
114
|
|
|
Commands\HydeMakePageCommand::class, |
115
|
|
|
Commands\HydeValidateCommand::class, |
116
|
|
|
// Commands\HydeInstallCommand::class, |
117
|
|
|
Commands\HydeDebugCommand::class, |
118
|
|
|
Commands\HydeServeCommand::class, |
119
|
|
|
|
120
|
|
|
Commands\HydePackageDiscoverCommand::class, |
121
|
|
|
]); |
122
|
|
|
} |
123
|
|
|
|
124
|
|
|
/** |
125
|
|
|
* Register module service providers. |
126
|
|
|
* |
127
|
|
|
* @todo #436 Make modules configurable. |
128
|
|
|
*/ |
129
|
|
|
protected function registerModuleServiceProviders(): void |
130
|
|
|
{ |
131
|
|
|
$this->app->register(Modules\DataCollections\DataCollectionServiceProvider::class); |
132
|
|
|
$this->app->register(Modules\Markdown\MarkdownServiceProvider::class); |
133
|
|
|
} |
134
|
|
|
} |
135
|
|
|
|