-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathHydeServiceProvider.php
118 lines (95 loc) · 3.53 KB
/
HydeServiceProvider.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
<?php
declare(strict_types=1);
namespace Hyde\Framework;
use Hyde\Console\HydeConsoleServiceProvider;
use Hyde\Foundation\HydeKernel;
use Hyde\Framework\Concerns\RegistersFileLocations;
use Hyde\Framework\Features\DataCollections\DataCollectionServiceProvider;
use Hyde\Framework\Features\Session\SessionServiceProvider;
use Hyde\Framework\Services\AssetService;
use Hyde\Framework\Services\YamlConfigurationService;
use Hyde\Framework\Views\Components\LinkComponent;
use Hyde\Hyde;
use Hyde\Markdown\MarkdownConverter;
use Hyde\Pages\BladePage;
use Hyde\Pages\DocumentationPage;
use Hyde\Pages\HtmlPage;
use Hyde\Pages\MarkdownPage;
use Hyde\Pages\MarkdownPost;
use Illuminate\Support\Facades\Blade;
use Illuminate\Support\ServiceProvider;
/**
* Register and bootstrap Hyde application services.
*/
class HydeServiceProvider extends ServiceProvider
{
use RegistersFileLocations;
/**
* Register any application services.
*/
public function register(): void
{
$this->initializeConfiguration();
$this->app->singleton(AssetService::class, AssetService::class);
$this->app->singleton(MarkdownConverter::class, function () {
return new MarkdownConverter();
});
Hyde::setSourceRoot(config('hyde.source_root', ''));
$this->registerSourceDirectories([
HtmlPage::class => '_pages',
BladePage::class => '_pages',
MarkdownPage::class => '_pages',
MarkdownPost::class => '_posts',
DocumentationPage::class => '_docs',
]);
$this->registerOutputDirectories([
HtmlPage::class => '',
BladePage::class => '',
MarkdownPage::class => '',
MarkdownPost::class => 'posts',
DocumentationPage::class => config('docs.output_directory', 'docs'),
]);
$this->storeCompiledSiteIn(config('site.output_directory', '_site'));
$this->discoverBladeViewsIn(BladePage::sourceDirectory());
$this->registerModuleServiceProviders();
}
/**
* Bootstrap any application services.
*/
public function boot(): void
{
$this->loadViewsFrom(__DIR__.'/../../resources/views', 'hyde');
$this->publishes([
__DIR__.'/../../config' => config_path(),
], 'configs');
$this->publishes([
__DIR__.'/../../resources/views/layouts' => resource_path('views/vendor/hyde/layouts'),
], 'hyde-layouts');
$this->publishes([
__DIR__.'/../../resources/views/components' => resource_path('views/vendor/hyde/components'),
], 'hyde-components');
$this->publishes([
Hyde::vendorPath('resources/views/pages/404.blade.php') => Hyde::path('_pages/404.blade.php'),
], 'hyde-page-404');
$this->publishes([
Hyde::vendorPath('resources/views/homepages/welcome.blade.php') => Hyde::path('_pages/index.blade.php'),
], 'hyde-welcome-page');
Blade::component('link', LinkComponent::class);
HydeKernel::getInstance()->boot();
}
protected function initializeConfiguration()
{
if (YamlConfigurationService::hasFile()) {
YamlConfigurationService::boot();
}
}
/**
* Register module service providers.
*/
protected function registerModuleServiceProviders(): void
{
$this->app->register(SessionServiceProvider::class);
$this->app->register(HydeConsoleServiceProvider::class);
$this->app->register(DataCollectionServiceProvider::class);
}
}