-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add the action to publish the frontend resources
- Loading branch information
1 parent
333f3b9
commit e2c82fb
Showing
2 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
|
||
namespace Hyde\Framework\Actions; | ||
|
||
use Hyde\Framework\Hyde; | ||
|
||
/** | ||
* Publishes default frontend resource files if they don't exist. | ||
* | ||
* This action is called when the Service Provider boots. | ||
* @see \Hyde\Framework\HydeServiceProvider | ||
* @todo Create option to disable this behaviour. | ||
*/ | ||
class PublishesDefaultFrontendResourceFiles | ||
{ | ||
public function __construct(protected ?bool $force = false) | ||
{ | ||
// | ||
} | ||
|
||
public function __invoke(): void | ||
{ | ||
$files = [ | ||
'app.css', | ||
'hyde.css', | ||
'hyde.js' | ||
]; | ||
|
||
if (! is_dir(Hyde::path('resources/frontend'))) { | ||
mkdir(Hyde::path('resources/frontend'), 0755, true); | ||
} | ||
|
||
foreach ($files as $file) { | ||
$this->handleFile($file); | ||
} | ||
} | ||
|
||
protected function handleFile(string $file): void | ||
{ | ||
Hyde::copy( | ||
Hyde::path('vendor/hyde/framework/resources/frontend/' . $file), | ||
Hyde::path('resources/frontend/' . $file), | ||
$this->force | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters