Skip to content

Commit

Permalink
Publish theme and publish demo theme commands added
Browse files Browse the repository at this point in the history
  • Loading branch information
HansSchouten committed Jun 19, 2020
1 parent fa8d51d commit a8dde6e
Show file tree
Hide file tree
Showing 6 changed files with 100 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Next, you need to create a theme:
- `php artisan pagebuilder:create-theme [name here]`

.. or publish the demo theme:
- `php artisan vendor:publish --provider="HansSchouten\LaravelPageBuilder\ServiceProvider" --tag=demo-theme`
- `php artisan pagebuilder:publish-demo`

Now you are able to login via `/admin` with `admin` and `changethispassword` (the admin URL and credentials can be changed in the pagebuilder config file).

Expand Down
2 changes: 2 additions & 0 deletions src/Commands/CreateTheme.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace HansSchouten\LaravelPageBuilder\Commands;

use Illuminate\Console\Command;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\File;
use Exception;

Expand Down Expand Up @@ -32,6 +33,7 @@ public function handle()
$themeName = $this->argument('name');
$themePath = base_path(config('pagebuilder.theme.folder_url') . '/' . $themeName);
File::copyDirectory(__DIR__ . '/../../themes/stub', $themePath);
Artisan::call('pagebuilder:publish-theme', ['theme' => $themeName]);
}

}
39 changes: 39 additions & 0 deletions src/Commands/PublishDemo.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

namespace HansSchouten\LaravelPageBuilder\Commands;

use Illuminate\Console\Command;
use Exception;
use Illuminate\Support\Facades\Artisan;

class PublishDemo extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'pagebuilder:publish-demo';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Publish the demo theme.';

/**
* Execute the console command.
*
* @throws Exception
*/
public function handle()
{
Artisan::call('vendor:publish', [
'--provider' => 'HansSchouten\LaravelPageBuilder\ServiceProvider',
'--tag' => 'demo-theme'
]);
Artisan::call('pagebuilder:publish-theme', ['theme' => 'demo']);
}

}
54 changes: 54 additions & 0 deletions src/Commands/PublishTheme.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php

namespace HansSchouten\LaravelPageBuilder\Commands;

use Illuminate\Console\Command;
use Exception;

class PublishTheme extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'pagebuilder:publish-theme {theme}';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Create for the given theme a folder in /public and symlink to the public folder of the theme.';

/**
* Execute the console command.
*
* @throws Exception
*/
public function handle()
{
$theme = basename($this->argument('theme'));

$themePublicFolder = config('pagebuilder.theme.folder') . "/{$theme}/public";
if (! file_exists($themePublicFolder)) {
return $this->error("The folder {$themePublicFolder} does not exist.");
}

if (! file_exists(public_path("themes"))) {
mkdir(public_path("themes"));
}

$publicThemeFolder = public_path("themes/{$theme}");
if (file_exists($publicThemeFolder)) {
return $this->error( "The 'public/{$theme}' directory already exists.");
}

$this->laravel->make('files')->link(
$themePublicFolder, $publicThemeFolder
);

return $this->info("The public directory of the {$theme} theme has been linked.");
}

}
4 changes: 4 additions & 0 deletions src/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
namespace HansSchouten\LaravelPageBuilder;

use HansSchouten\LaravelPageBuilder\Commands\CreateTheme;
use HansSchouten\LaravelPageBuilder\Commands\PublishDemo;
use HansSchouten\LaravelPageBuilder\Commands\PublishTheme;

class ServiceProvider extends \Illuminate\Support\ServiceProvider
{
Expand All @@ -28,6 +30,8 @@ public function boot()
if ($this->app->runningInConsole()) {
$this->commands([
CreateTheme::class,
PublishTheme::class,
PublishDemo::class,
]);
}

Expand Down
File renamed without changes.

0 comments on commit a8dde6e

Please sign in to comment.