Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
10 / 10 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| PublishesHydeViews | |
100.00% |
10 / 10 |
|
100.00% |
2 / 2 |
4 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| execute | |
100.00% |
9 / 9 |
|
100.00% |
1 / 1 |
3 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace Hyde\Framework\Actions; |
| 4 | |
| 5 | use Hyde\Framework\Contracts\ActionContract; |
| 6 | use Hyde\Framework\Hyde; |
| 7 | use Illuminate\Support\Facades\File; |
| 8 | |
| 9 | /* |
| 10 | * Publish one or more of the Hyde Blade views. |
| 11 | * |
| 12 | * @see \Tests\Feature\Actions\PublishesHomepageViewTest |
| 13 | */ |
| 14 | class PublishesHydeViews implements ActionContract |
| 15 | { |
| 16 | public static array $options = [ |
| 17 | 'layouts' => [ |
| 18 | 'name' => 'Blade Layouts', |
| 19 | 'path' => 'resources/views/layouts', |
| 20 | 'destination' => 'resources/views/vendor/hyde/layouts', |
| 21 | 'description' => 'Shared layout views, such as the app layout, navigation menu, and Markdown page templates.', |
| 22 | ], |
| 23 | 'components' => [ |
| 24 | 'name' => 'Blade Components', |
| 25 | 'path' => 'resources/views/components', |
| 26 | 'destination' => 'resources/views/vendor/hyde/components', |
| 27 | 'description' => 'More or less self contained components, extracted for customizability and DRY code.', |
| 28 | ], |
| 29 | '404' => [ |
| 30 | 'name' => '404 Page', |
| 31 | 'path' => 'resources/views/pages/404.blade.php', |
| 32 | 'destination' => '_pages/404.blade.php', |
| 33 | 'description' => 'A beautiful 404 error page by the Laravel Collective.', |
| 34 | ], |
| 35 | ]; |
| 36 | |
| 37 | protected string $selected; |
| 38 | |
| 39 | public function __construct(string $selected) |
| 40 | { |
| 41 | $this->selected = $selected; |
| 42 | } |
| 43 | |
| 44 | public function execute(): bool|int |
| 45 | { |
| 46 | if (! array_key_exists($this->selected, self::$options)) { |
| 47 | return 404; |
| 48 | } |
| 49 | |
| 50 | if (is_dir(Hyde::vendorPath(static::$options[$this->selected]['path']))) { |
| 51 | return File::copyDirectory( |
| 52 | Hyde::vendorPath(static::$options[$this->selected]['path']), |
| 53 | Hyde::path(static::$options[$this->selected]['destination']) |
| 54 | ); |
| 55 | } |
| 56 | |
| 57 | return File::copy( |
| 58 | Hyde::vendorPath(static::$options[$this->selected]['path']), |
| 59 | Hyde::path(static::$options[$this->selected]['destination']) |
| 60 | ); |
| 61 | } |
| 62 | } |