Passed
Push — master ( 1230fe...ada723 )
by Caen
03:10 queued 12s
created

HydeServiceProvider::register()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 31
Code Lines 19

Duplication

Lines 0
Ratio 0 %

Importance

Changes 6
Bugs 0 Features 0
Metric Value
cc 1
eloc 19
c 6
b 0
f 0
nc 1
nop 0
dl 0
loc 31
rs 9.6333
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Hyde\Framework;
6
7
use Hyde\Facades\Features;
8
use Hyde\Foundation\HydeKernel;
9
use Hyde\Framework\Concerns\RegistersFileLocations;
10
use Hyde\Framework\Services\AssetService;
11
use Hyde\Pages\BladePage;
12
use Hyde\Pages\DocumentationPage;
13
use Hyde\Pages\HtmlPage;
14
use Hyde\Pages\MarkdownPage;
15
use Hyde\Pages\MarkdownPost;
16
use Illuminate\Support\ServiceProvider;
17
18
/**
19
 * Register and bootstrap core Hyde application services.
20
 */
21
class HydeServiceProvider extends ServiceProvider
22
{
23
    use RegistersFileLocations;
24
25
    protected HydeKernel $kernel;
26
27
    public function register(): void
28
    {
29
        $this->kernel = HydeKernel::getInstance();
30
31
        $this->app->singleton(AssetService::class, AssetService::class);
32
33
        $this->kernel->setSourceRoot(config('hyde.source_root', ''));
34
35
        $this->registerPageModels();
36
37
        $this->registerSourceDirectories([
38
            HtmlPage::class => '_pages',
39
            BladePage::class => '_pages',
40
            MarkdownPage::class => '_pages',
41
            MarkdownPost::class => '_posts',
42
            DocumentationPage::class => '_docs',
43
        ]);
44
45
        $this->registerOutputDirectories([
46
            HtmlPage::class => '',
47
            BladePage::class => '',
48
            MarkdownPage::class => '',
49
            MarkdownPost::class => 'posts',
50
            DocumentationPage::class => config('docs.output_directory', 'docs'),
51
        ]);
52
53
        $this->storeCompiledSiteIn(config('site.output_directory', '_site'));
54
55
        $this->useMediaDirectory(config('site.media_directory', '_media'));
56
57
        $this->discoverBladeViewsIn(BladePage::sourceDirectory());
58
    }
59
60
    public function boot(): void
61
    {
62
        $this->kernel->readyToBoot();
63
    }
64
65
    protected function registerPageModels(): void
66
    {
67
        if (Features::hasHtmlPages()) {
68
            $this->kernel->registerPageClass(HtmlPage::class);
0 ignored issues
show
Deprecated Code introduced by
The function Hyde\Foundation\HydeKernel::registerPageClass() has been deprecated: This feature may be replaced by the {@see \Hyde\Foundation\Concerns\HydeExtension} system. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

68
            /** @scrutinizer ignore-deprecated */ $this->kernel->registerPageClass(HtmlPage::class);

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
69
        }
70
71
        if (Features::hasBladePages()) {
72
            $this->kernel->registerPageClass(BladePage::class);
0 ignored issues
show
Deprecated Code introduced by
The function Hyde\Foundation\HydeKernel::registerPageClass() has been deprecated: This feature may be replaced by the {@see \Hyde\Foundation\Concerns\HydeExtension} system. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

72
            /** @scrutinizer ignore-deprecated */ $this->kernel->registerPageClass(BladePage::class);

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
73
        }
74
75
        if (Features::hasMarkdownPages()) {
76
            $this->kernel->registerPageClass(MarkdownPage::class);
0 ignored issues
show
Deprecated Code introduced by
The function Hyde\Foundation\HydeKernel::registerPageClass() has been deprecated: This feature may be replaced by the {@see \Hyde\Foundation\Concerns\HydeExtension} system. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

76
            /** @scrutinizer ignore-deprecated */ $this->kernel->registerPageClass(MarkdownPage::class);

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
77
        }
78
79
        if (Features::hasMarkdownPosts()) {
80
            $this->kernel->registerPageClass(MarkdownPost::class);
0 ignored issues
show
Deprecated Code introduced by
The function Hyde\Foundation\HydeKernel::registerPageClass() has been deprecated: This feature may be replaced by the {@see \Hyde\Foundation\Concerns\HydeExtension} system. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

80
            /** @scrutinizer ignore-deprecated */ $this->kernel->registerPageClass(MarkdownPost::class);

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
81
        }
82
83
        if (Features::hasDocumentationPages()) {
84
            $this->kernel->registerPageClass(DocumentationPage::class);
0 ignored issues
show
Deprecated Code introduced by
The function Hyde\Foundation\HydeKernel::registerPageClass() has been deprecated: This feature may be replaced by the {@see \Hyde\Foundation\Concerns\HydeExtension} system. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

84
            /** @scrutinizer ignore-deprecated */ $this->kernel->registerPageClass(DocumentationPage::class);

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
85
        }
86
    }
87
}
88