-
-
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.
feat: add theme publishing functionality, UI button and a new command…
… `igniter:theme-publish` Signed-off-by: Sam Poyigi <[email protected]>
- Loading branch information
Showing
10 changed files
with
138 additions
and
36 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
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
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
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
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
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
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
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
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,72 @@ | ||
<?php | ||
|
||
namespace Igniter\System\Console\Commands; | ||
|
||
use Igniter\Flame\Exception\SystemException; | ||
use Igniter\Flame\Igniter; | ||
use Igniter\Main\Classes\Theme; | ||
use Igniter\Main\Classes\ThemeManager; | ||
use Illuminate\Foundation\Console\VendorPublishCommand; | ||
use Symfony\Component\Console\Input\InputOption; | ||
|
||
class ThemePublish extends VendorPublishCommand | ||
{ | ||
use \Illuminate\Console\ConfirmableTrait; | ||
|
||
protected $name = 'igniter:theme-publish'; | ||
|
||
protected $description = 'Publish any publishable theme files from extensions'; | ||
|
||
protected $signature; | ||
|
||
protected ?Theme $activeTheme; | ||
|
||
/** | ||
* Execute the console command. | ||
* @return void | ||
*/ | ||
public function handle() | ||
{ | ||
$this->determineWhatShouldBePublished(); | ||
|
||
$published = false; | ||
|
||
$activeThemePath = $this->activeTheme->getPath(); | ||
foreach (Igniter::publishableThemeFiles() as $path => $publishTo) { | ||
$this->publishItem($path, $activeThemePath.'/'.$publishTo); | ||
$published = true; | ||
} | ||
|
||
if ($published === false) { | ||
$this->comment('No publishable custom files for theme ['.$this->activeTheme->getName().'].'); | ||
} | ||
|
||
$this->info('Publishing complete.'); | ||
} | ||
|
||
protected function determineWhatShouldBePublished() | ||
{ | ||
throw_unless( | ||
$this->activeTheme = resolve(ThemeManager::class)->getActiveTheme(), | ||
new SystemException(lang('igniter::admin.alert_error_nothing')) | ||
); | ||
|
||
throw_if( | ||
$this->activeTheme->locked, | ||
new SystemException(lang('igniter::system.themes.alert_theme_locked')) | ||
); | ||
|
||
throw_if( | ||
!str_starts_with($this->activeTheme->getPath(), theme_path()), | ||
new SystemException(lang('igniter::system.themes.alert_no_publish_custom')) | ||
); | ||
} | ||
|
||
protected function getOptions() | ||
{ | ||
return [ | ||
['existing', null, InputOption::VALUE_NONE, 'Publish and overwrite only the files that have already been published'], | ||
['force', null, InputOption::VALUE_NONE, 'Force publish.'], | ||
]; | ||
} | ||
} |
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