-
Notifications
You must be signed in to change notification settings - Fork 9
/
Plugin.php
70 lines (61 loc) · 2.01 KB
/
Plugin.php
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
60
61
62
63
64
65
66
67
68
69
70
<?php
namespace Cyd293\BackendSkin;
use Backend\Classes\Skin as AbstractSkin;
use Backend\Classes\WidgetBase;
use Backend;
use Config;
use Cyd293\BackendSkin\Listener\PluginEventSubscriber;
use Cyd293\BackendSkin\Models\Settings;
use Cyd293\BackendSkin\Router\UrlGenerator;
use Cyd293\BackendSkin\Skin\BackendSkin;
use Event;
use System\Classes\PluginBase;
class Plugin extends PluginBase
{
public $elevated = true;
public function boot()
{
$this->app->instance('path.backendskins', $this->backendSkinPaths());
Config::set('cms.backendSkin', BackendSkin::class);
Config::set('backend.skin', BackendSkin::class);
Event::subscribe(new PluginEventSubscriber());
WidgetBase::extendableExtendCallback(function (WidgetBase $widget) {
$origViewPath = $widget->guessViewPath();
$newViewPath = str_replace(base_path(), '', $origViewPath);
$newViewPath = $this->getActiveSkin()->skinPath . '/views/' . $newViewPath . '/partials';
$widget->addViewPath($newViewPath);
});
}
public function backendSkinPaths()
{
return base_path() . '/backendskins';
}
public function registerComponents()
{
}
public function registerSettings()
{
return [
'settings' => [
'label' => 'cyd293.backendskin::lang.settings.label',
'description' => 'cyd293.backendskin::lang.settings.description',
'category' => 'system::lang.system.categories.cms',
'class' => Settings::class,
'icon' => 'icon-picture-o',
'order' => 500,
],
];
}
public function register()
{
$this->app->register(RoutingServiceProvider::class);
$this->registerConsoleCommand('cyd293.backendskin', Console\SetSkinCommand::class);
}
/**
* @return AbstractSkin
*/
private function getActiveSkin()
{
return AbstractSkin::getActive();
}
}