Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
7 / 7 |
|
100.00% |
5 / 5 |
CRAP | |
100.00% |
1 / 1 |
DocumentationSearchPage | |
100.00% |
7 / 7 |
|
100.00% |
5 / 5 |
6 | |
100.00% |
1 / 1 |
generate | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
__construct | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
1 | |||
compile | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
enabled | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
2 | |||
routeKey | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | |
3 | declare(strict_types=1); |
4 | |
5 | namespace Hyde\Framework\Features\Documentation; |
6 | |
7 | use Hyde\Hyde; |
8 | use Hyde\Pages\DocumentationPage; |
9 | use Hyde\Framework\Actions\StaticPageBuilder; |
10 | use Hyde\Facades\Config; |
11 | use Illuminate\Support\Facades\View; |
12 | |
13 | /** |
14 | * @internal This page is used to render the search page for the documentation. |
15 | * |
16 | * It is not based on a source file, but is dynamically generated when the Search feature is enabled. |
17 | * If you want to override this page, you can create a page with the route key "docs/search", |
18 | * then this class will not be applied. For example, `_pages/docs/search.blade.php`. |
19 | */ |
20 | class DocumentationSearchPage extends DocumentationPage |
21 | { |
22 | /** |
23 | * Generate the search page and save it to disk. |
24 | * |
25 | * @return string The path to the generated file. |
26 | */ |
27 | public static function generate(): string |
28 | { |
29 | return StaticPageBuilder::handle(new static()); |
30 | } |
31 | |
32 | /** |
33 | * Create a new DocumentationSearchPage instance. |
34 | */ |
35 | public function __construct() |
36 | { |
37 | parent::__construct('search', [ |
38 | 'title' => 'Search', |
39 | ]); |
40 | } |
41 | |
42 | public function compile(): string |
43 | { |
44 | return View::make('hyde::pages.documentation-search')->render(); |
45 | } |
46 | |
47 | public static function enabled(): bool |
48 | { |
49 | return Config::getBool('docs.create_search_page', true) && ! Hyde::routes()->has(self::routeKey()); |
50 | } |
51 | |
52 | public static function routeKey(): string |
53 | { |
54 | return parent::outputDirectory().'/search'; |
55 | } |
56 | } |