1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace SleepingOwl\Admin\Providers; |
4
|
|
|
|
5
|
|
|
use Illuminate\View\Factory; |
6
|
|
|
use SleepingOwl\Admin\Admin; |
7
|
|
|
use Illuminate\View\FileViewFinder; |
8
|
|
|
use Illuminate\View\Engines\PhpEngine; |
9
|
|
|
use Illuminate\View\Engines\EngineResolver; |
10
|
|
|
|
11
|
|
|
class SleepingOwlServiceProvider extends AdminSectionsServiceProvider |
12
|
|
|
{ |
13
|
285 |
|
public function register() |
14
|
|
|
{ |
15
|
285 |
|
$this->mergeConfigFrom(__DIR__.'/../../config/sleeping_owl.php', 'sleeping_owl'); |
16
|
285 |
|
$this->loadViewsFrom(__DIR__.'/../../resources/views', 'sleeping_owl'); |
17
|
|
|
|
18
|
285 |
|
$this->registerCore(); |
19
|
285 |
|
$this->registerCommands(); |
20
|
285 |
|
} |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* @param Admin $admin |
24
|
|
|
*/ |
25
|
285 |
|
public function boot(Admin $admin) |
26
|
|
|
{ |
27
|
285 |
|
$this->loadTranslationsFrom(__DIR__.'/../../resources/lang', 'sleeping_owl'); |
28
|
|
|
|
29
|
285 |
|
if ($this->app->runningInConsole()) { |
30
|
285 |
|
$this->publishes([ |
31
|
285 |
|
__DIR__.'/../../public' => public_path('packages/sleepingowl/'), |
32
|
285 |
|
], 'assets'); |
33
|
|
|
|
34
|
285 |
|
$this->publishes([ |
35
|
285 |
|
__DIR__.'/../../config/sleeping_owl.php' => config_path('sleeping_owl.php'), |
36
|
285 |
|
], 'config'); |
37
|
285 |
|
} |
38
|
|
|
|
39
|
285 |
|
parent::boot($admin); |
40
|
285 |
|
} |
41
|
|
|
|
42
|
285 |
|
protected function registerCore() |
43
|
|
|
{ |
44
|
285 |
|
$this->app->instance('sleeping_owl', $admin = new Admin($this->app)); |
45
|
285 |
|
$admin->setTemplate($this->app['sleeping_owl.template']); |
46
|
285 |
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* @return Factory |
50
|
|
|
*/ |
51
|
285 |
|
private function createLocalViewFactory() |
52
|
|
|
{ |
53
|
285 |
|
$resolver = new EngineResolver(); |
54
|
|
|
$resolver->register('php', function () { |
55
|
|
|
return new PhpEngine(); |
56
|
285 |
|
}); |
57
|
285 |
|
$finder = new FileViewFinder($this->app['files'], [__DIR__.'/../../resources/views']); |
58
|
285 |
|
$factory = new Factory($resolver, $finder, $this->app['events']); |
59
|
285 |
|
$factory->addExtension('php', 'php'); |
60
|
|
|
|
61
|
285 |
|
return $factory; |
62
|
285 |
|
} |
63
|
|
|
|
64
|
285 |
|
protected function registerCommands() |
65
|
|
|
{ |
66
|
285 |
|
if ($this->app->runningInConsole()) { |
67
|
285 |
|
$this->commands([ |
68
|
285 |
|
\SleepingOwl\Admin\Console\Commands\InstallCommand::class, |
69
|
285 |
|
\SleepingOwl\Admin\Console\Commands\UpdateCommand::class, |
70
|
285 |
|
\SleepingOwl\Admin\Console\Commands\UserManagerCommand::class, |
71
|
285 |
|
\SleepingOwl\Admin\Console\Commands\SectionGenerate::class, |
72
|
285 |
|
\SleepingOwl\Admin\Console\Commands\SectionMake::class, |
73
|
285 |
|
\SleepingOwl\Admin\Console\Commands\SectionProvider::class, |
74
|
285 |
|
]); |
75
|
|
|
|
76
|
285 |
|
$localViewFactory = $this->createLocalViewFactory(); |
77
|
285 |
|
$this->app->singleton( |
78
|
285 |
|
'command.sleepingowl.ide.generate', |
79
|
|
|
function ($app) use ($localViewFactory) { |
80
|
|
|
return new \SleepingOwl\Admin\Console\Commands\GeneratorCommand($app['config'], $app['files'], $localViewFactory); |
81
|
|
|
} |
82
|
285 |
|
); |
83
|
|
|
|
84
|
285 |
|
$this->commands('command.sleepingowl.ide.generate'); |
85
|
285 |
|
} |
86
|
285 |
|
} |
87
|
|
|
} |
88
|
|
|
|