-
Notifications
You must be signed in to change notification settings - Fork 195
Expand file tree
/
Copy pathServiceProvider.php
More file actions
59 lines (52 loc) · 1.96 KB
/
ServiceProvider.php
File metadata and controls
59 lines (52 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
namespace HansSchouten\LaravelPageBuilder;
use Illuminate\Support\Facades\Schema;
use HansSchouten\LaravelPageBuilder\Commands\CreateTheme;
use HansSchouten\LaravelPageBuilder\Commands\PublishDemo;
use HansSchouten\LaravelPageBuilder\Commands\PublishTheme;
use PHPageBuilder\PHPageBuilder;
use Exception;
class ServiceProvider extends \Illuminate\Support\ServiceProvider
{
/**
* Register services.
*
* @return void
*/
public function register()
{
}
/**
* Bootstrap services.
*
* @return void
* @throws Exception
*/
public function boot()
{
$this->loadRoutesFrom(__DIR__ . '/../routes/web.php');
$this->loadMigrationsFrom(__DIR__ . '/../migrations');
$this->publishes([
__DIR__ . '/../config/pagebuilder.php' => config_path('pagebuilder.php'),
], 'config');
if (Schema::hasTable(config('pagebuilder.storage.database.prefix') . 'settings')) {
if ($this->app->runningInConsole()) {
$this->commands([
CreateTheme::class,
PublishTheme::class,
PublishDemo::class,
]);
} elseif (empty(config('pagebuilder'))) {
throw new Exception("No PHPageBuilder config found, please run: php artisan vendor:publish --provider=\"HansSchouten\LaravelPageBuilder\ServiceProvider\" --tag=config");
}
// register singleton phpPageBuilder (this ensures phpb_ helpers have the right config without first manually creating a PHPageBuilder instance)
$this->app->singleton('phpPageBuilder', function ($app) {
return new PHPageBuilder(config('pagebuilder') ?? []);
});
$this->app->make('phpPageBuilder');
$this->publishes([
__DIR__ . '/../themes/demo' => base_path(config('pagebuilder.theme.folder_url') . '/demo'),
], 'demo-theme');
}
}
}