Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
22 / 22
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
HydeServiceProvider
100.00% covered (success)
100.00%
22 / 22
100.00% covered (success)
100.00%
2 / 2
2
100.00% covered (success)
100.00%
1 / 1
 register
100.00% covered (success)
100.00%
21 / 21
100.00% covered (success)
100.00%
1 / 1
1
 boot
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3declare(strict_types=1);
4
5namespace Hyde\Framework;
6
7use Hyde\Pages\HtmlPage;
8use Hyde\Pages\BladePage;
9use Hyde\Pages\MarkdownPage;
10use Hyde\Pages\MarkdownPost;
11use Hyde\Foundation\HydeKernel;
12use Hyde\Pages\DocumentationPage;
13use Hyde\Framework\Services\AssetService;
14use Hyde\Framework\Services\BuildTaskService;
15use Hyde\Framework\Concerns\RegistersFileLocations;
16use Illuminate\Support\ServiceProvider;
17use Hyde\Facades\Config;
18
19/**
20 * Register and bootstrap core Hyde application services.
21 */
22class HydeServiceProvider extends ServiceProvider
23{
24    use RegistersFileLocations;
25
26    protected HydeKernel $kernel;
27
28    public function register(): void
29    {
30        $this->kernel = HydeKernel::getInstance();
31
32        $this->app->singleton(AssetService::class, AssetService::class);
33        $this->app->singleton(BuildTaskService::class, BuildTaskService::class);
34
35        $this->kernel->setSourceRoot(Config::getString('hyde.source_root', ''));
36
37        $this->registerSourceDirectories([
38            HtmlPage::class => $this->getSourceDirectoryConfiguration(HtmlPage::class, '_pages'),
39            BladePage::class => $this->getSourceDirectoryConfiguration(BladePage::class, '_pages'),
40            MarkdownPage::class => $this->getSourceDirectoryConfiguration(MarkdownPage::class, '_pages'),
41            MarkdownPost::class => $this->getSourceDirectoryConfiguration(MarkdownPost::class, '_posts'),
42            DocumentationPage::class => $this->getSourceDirectoryConfiguration(DocumentationPage::class, '_docs'),
43        ]);
44
45        $this->registerOutputDirectories([
46            HtmlPage::class => $this->getOutputDirectoryConfiguration(HtmlPage::class, ''),
47            BladePage::class => $this->getOutputDirectoryConfiguration(BladePage::class, ''),
48            MarkdownPage::class => $this->getOutputDirectoryConfiguration(MarkdownPage::class, ''),
49            MarkdownPost::class => $this->getOutputDirectoryConfiguration(MarkdownPost::class, 'posts'),
50            DocumentationPage::class => $this->getOutputDirectoryConfiguration(DocumentationPage::class, 'docs'),
51        ]);
52
53        $this->storeCompiledSiteIn(Config::getString('hyde.output_directory', '_site'));
54
55        $this->useMediaDirectory(Config::getString('hyde.media_directory', '_media'));
56
57        $this->discoverBladeViewsIn(BladePage::sourceDirectory());
58    }
59
60    public function boot(): void
61    {
62        //
63    }
64}