-
Notifications
You must be signed in to change notification settings - Fork 0
/
Plugin.php
159 lines (147 loc) · 4.64 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
<?php namespace SpAnjaan\Snowflake;
use Backend;
use Backend\Models\UserRole;
use System\Classes\PluginBase;
use SpAnjaan\Snowflake\Classes\SnowflakeParser;
use SpAnjaan\Snowflake\Models\Settings;
use Winter\Storm\Support\Facades\Event;
/**
* Snowflake Plugin Information File
*/
class Plugin extends PluginBase
{
/**
* Returns information about this plugin.
*
* @return array
*/
public function pluginDetails(): array
{
return [
'name' => 'spanjaan.snowflake::lang.plugin.name',
'description' => 'spanjaan.snowflake::lang.plugin.description',
'author' => 'SpAnjaan',
'icon' => 'icon-snowflake',
];
}
/**
* Register method, called when the plugin is first registered.
*
* @return void
*/
public function register(): void
{
Event::listen('cms.template.save', function ($controller, $templateObject, $type) {
if (!in_array($type, ['page', 'layout', 'partial'], true)) {
return;
}
SnowflakeParser::parseSnowflake($templateObject, $type);
});
$this->registerConsoleCommand('snowflake.sync', 'SpAnjaan\Snowflake\Console\SyncCommand');
}
/**
* Boot method, called right before the request route.
*
* @return void
*/
public function boot(): void
{
// Optionally include boot logic here
}
/**
* Registers any frontend components implemented in this plugin.
*
* @return array
*/
public function registerComponents(): array
{
return [
\SpAnjaan\Snowflake\Components\SfPage::class => 'sf_page',
];
}
/**
* Registers any backend permissions used by this plugin.
*
* @return array
*/
public function registerPermissions(): array
{
return [
'spanjaan.snowflake.use_snowflake' => [
'tab' => 'Snowflake',
'label' => 'spanjaan.snowflake::lang.plugin.use_snowflake',
],
'spanjaan.snowflake.manage_snowflake' => [
'tab' => 'Snowflake',
'label' => 'spanjaan.snowflake::lang.plugin.manage_snowflake',
],
];
}
/**
* Registers backend navigation items for this plugin.
*
* @return array
*/
public function registerNavigation(): array
{
$label = Settings::get('custom_name') ?: 'Snowflake';
return [
'snowflake' => [
'label' => $label,
'url' => Backend::url('spanjaan/snowflake/pages'),
'iconSvg' => 'plugins/spanjaan/snowflake/assets/icons/snowflake-blue.svg',
'permissions' => ['spanjaan.snowflake.*'],
'order' => 500,
'sideMenu' => [
'pages' => [
'label' => 'spanjaan.snowflake::lang.models.page.label_plural',
'url' => Backend::url('spanjaan/snowflake/pages'),
'icon' => 'wn-icon-copy',
'permissions' => ['spanjaan.snowflake.*'],
],
'layouts' => [
'label' => 'spanjaan.snowflake::lang.models.layout.label_plural',
'url' => Backend::url('spanjaan/snowflake/layouts'),
'icon' => 'wn-icon-th-large',
'permissions' => ['spanjaan.snowflake.*'],
],
],
],
];
}
/**
* Registers settings for this plugin.
*
* @return array
*/
public function registerSettings(): array
{
return [
'snowflake' => [
'label' => 'spanjaan.snowflake::lang.plugin.name',
'description' => 'spanjaan.snowflake::lang.plugin.manage_settings',
'category' => 'system::lang.system.categories.cms',
'icon' => 'icon-snowflake',
'class' => 'SpAnjaan\Snowflake\Models\Settings',
'order' => 500,
'keywords' => 'snowflake',
'permissions' => ['spanjaan.snowflake.manage_snowflake'],
],
];
}
/**
* Registers markup tags for this plugin.
*
* @return array
*/
public function registerMarkupTags(): array
{
return [
'filters' => [
'sf' => function ($cms_key) {
return $cms_key;
},
],
];
}
}