Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| StaticPageBuilder | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
| handle | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Hyde\Framework\Actions; |
| 6 | |
| 7 | use Hyde\Hyde; |
| 8 | use Hyde\Facades\Filesystem; |
| 9 | use Hyde\Framework\Concerns\InteractsWithDirectories; |
| 10 | use Hyde\Pages\Concerns\HydePage; |
| 11 | |
| 12 | /** |
| 13 | * Converts a Hyde page object into a static HTML page. |
| 14 | */ |
| 15 | class StaticPageBuilder |
| 16 | { |
| 17 | use InteractsWithDirectories; |
| 18 | |
| 19 | /** |
| 20 | * Invoke the static page builder for the given page. |
| 21 | */ |
| 22 | public static function handle(HydePage $page): string |
| 23 | { |
| 24 | $path = Hyde::sitePath($page->getOutputPath()); |
| 25 | |
| 26 | static::needsParentDirectory($path); |
| 27 | |
| 28 | Hyde::shareViewData($page); |
| 29 | |
| 30 | Filesystem::putContents($path, $page->compile()); |
| 31 | |
| 32 | return $path; |
| 33 | } |
| 34 | } |