-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPlugin.php
executable file
·170 lines (154 loc) · 4.18 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
160
161
162
163
164
165
166
167
168
169
170
<?php
namespace RLuders\Socialize;
use Auth;
use RainLab\User\Models\User;
use System\Classes\PluginBase;
use System\Classes\SettingsManager;
use RLuders\Socialize\Models\Settings;
/**
* Socialize Plugin Information File.
*/
class Plugin extends PluginBase
{
/**
* Plugin dependencies.
*
* @var array
*/
public $require = [
'RainLab.User'
];
/**
* Returns information about this plugin.
*
* @return array
*/
public function pluginDetails()
{
return [
'name' => 'rluders.socialize::lang.plugin.name',
'description' => 'rluders.socialize::lang.plugin.description',
'author' => 'Ricardo Lüders',
'icon' => 'icon-user-secret',
];
}
/**
* Register the plugin settings
*
* @return array
*/
public function registerSettings()
{
return [];
// return [
// 'settings' => [
// 'label' => 'rluders.socialize::lang.settings.menu_label',
// 'description' => 'rluders.socialize::lang.settings.menu_description',
// 'category' => 'rluders.socialize::lang.system.categories.socialize',
// 'icon' => 'icon-cog',
// 'class' => 'RLuders\Socialize\Models\Settings',
// 'order' => 500,
// 'permissions' => ['rluders.socialize.access_settings'],
// ]
// ];
}
/**
* Register plugin permissions
*
* @return array
*/
public function registerPermissions()
{
return [
'rluders.socialize.access_settings' => [
'tab' => 'rluders.socialize::lang.plugin.name',
'label' => 'rluders.socialize::lang.permissions.settings'
]
];
}
/**
* Get active plugin's modules
*
* @return array
*/
protected function getPluginModules()
{
return Settings::instance()->getActiveModules();
}
/**
* Get the namespace + class to the module's service provider
*
* @param string $module
* @return string
*/
protected function getPluginModuleServiceProviderClassName($module)
{
return '\\RLuders\\Socialize\\Modules\\' .
ucfirst($module) . '\\' .
ucfirst($module) . 'ServiceProvider';
}
/**
* Register method, called when the plugin is first registered.
*
* @return void
*/
public function register()
{
//
}
/**
* Plugin bootstrap
*
* @return void
*/
public function boot()
{
$modules = $this->getPluginModules();
foreach ($modules as $module) {
$className = $this->getPluginModuleServiceProviderClassName($module);
if (class_exists($className)) {
$this->app->register($className);
}
}
}
/**
* Register plugin components
*
* @return array
*/
public function registerComponents()
{
$components = [];
$modules = $this->getPluginModules();
foreach ($modules as $module) {
$className = $this->getPluginModuleServiceProviderClassName($module);
if (class_exists($className) && method_exists($className, 'getComponents')) {
$components = array_merge_recursive(
$components,
$className::getComponents()
);
}
}
return $components;
}
/**
* Register the markuptags for the template engine
*
* @return array
*/
public function registerMarkupTags()
{
$markupTags = [];
$modules = $this->getPluginModules();
foreach ($modules as $module) {
$className = $this->getPluginModuleServiceProviderClassName($module);
if (class_exists($className) && method_exists($className, 'getMarkupTags')) {
$markupTags = array_merge_recursive(
$markupTags,
$className::getMarkupTags()
);
}
}
return $markupTags;
}
}