-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlugin.php
More file actions
167 lines (152 loc) · 5.23 KB
/
Plugin.php
File metadata and controls
167 lines (152 loc) · 5.23 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
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
<?php namespace Webmaxx\Forms;
use Backend;
use Backend\Models\UserRole;
use System\Classes\PluginBase;
use Webmaxx\Forms\Models\Feedback;
use Webmaxx\Forms\NotifyRules\FeedbackFormAttributeCondition;
use Webmaxx\Forms\NotifyRules\FeedbackFormSentNotifyEvent;
use Webmaxx\Forms\NotifyRules\FormCodeCondition;
use Winter\Notify\Classes\Notifier;
/**
* Forms Plugin Information File
*/
class Plugin extends PluginBase
{
/**
* @var array Plugin dependencies
*/
public $require = [
// 'Winter.Notify', // Optional
];
/**
* Returns information about this plugin.
*/
public function pluginDetails(): array
{
return [
'name' => 'webmaxx.forms::lang.plugin.name',
'description' => 'webmaxx.forms::lang.plugin.description',
'author' => 'Webmaxx',
'homepage' => 'https://github.com/webmaxx/wn-forms-plugin',
'icon' => 'icon-envelope'
];
}
/**
* Register method, called when the plugin is first registered.
*/
public function register(): void
{
$this->bindNotificationEvents();
}
/**
* Boot method, called right before the request route.
*/
public function boot(): void
{
}
/**
* Registers any frontend components implemented in this plugin.
*/
public function registerComponents(): array
{
return [
'Webmaxx\Forms\Components\FeedbackForm' => 'wmFeedbackForm',
];
}
/**
* Registers any backend permissions used by this plugin.
*/
public function registerPermissions(): array
{
return [
// Feedbacks
'webmaxx.forms.feedbacks_access' => [
'tab' => 'webmaxx.forms::lang.plugin.name',
'label' => 'webmaxx.forms::lang.permissions.feedbacks_access',
'roles' => [UserRole::CODE_DEVELOPER, UserRole::CODE_PUBLISHER],
],
// // Forms
// 'webmaxx.forms.builder_access' => [
// 'tab' => 'webmaxx.forms::lang.plugin.name',
// 'label' => 'webmaxx.forms::lang.permissions.builder_access',
// 'roles' => [UserRole::CODE_DEVELOPER, UserRole::CODE_PUBLISHER],
// ],
// // Records
// 'webmaxx.forms.records_access' => [
// 'tab' => 'webmaxx.forms::lang.plugin.name',
// 'label' => 'webmaxx.forms::lang.permissions.records_access',
// 'roles' => [UserRole::CODE_DEVELOPER, UserRole::CODE_PUBLISHER],
// ],
];
}
/**
* Registers backend navigation items for this plugin.
*/
public function registerNavigation(): array
{
return [
'forms' => [
'label' => 'webmaxx.forms::lang.navigation.forms.label',
'url' => Backend::url('webmaxx/forms'),
'icon' => 'icon-envelope',
'permissions' => ['webmaxx.forms.*'],
'order' => 500,
'sideMenu' => [
'feedbacks' => [
'label' => 'webmaxx.forms::lang.navigation.forms.sidemenu.feedbacks',
'url' => Backend::url('webmaxx/forms/feedbacks'),
'icon' => 'icon-comment',
'permissions' => ['webmaxx.forms.feedbacks_access'],
'counter' => [Feedback::class, 'getNewCount'],
],
// 'builder' => [
// 'label' => 'webmaxx.forms::lang.navigation.forms.sidemenu.builder',
// 'url' => Backend::url('webmaxx/forms/builder'),
// 'icon' => 'icon-wrench',
// 'permissions' => ['webmaxx.forms.builder_access'],
// ],
// 'records' => [
// 'label' => 'webmaxx.forms::lang.navigation.forms.sidemenu.records',
// 'url' => Backend::url('webmaxx/forms/records'),
// 'icon' => 'icon-envelope',
// 'permissions' => ['webmaxx.forms.records_access'],
// ],
],
],
];
}
public function registerMailTemplates()
{
return [
'webmaxx.forms::mail.feedback' => '[Forms] Feedback',
];
}
public function registerNotificationRules()
{
return [
'events' => [
FeedbackFormSentNotifyEvent::class,
],
'actions' => [],
'conditions' => [
FormCodeCondition::class,
FeedbackFormAttributeCondition::class,
],
'groups' => [
'webmaxx.forms' => [
'label' => 'webmaxx.forms::lang.navigation.forms.label',
'icon' => 'icon-envelope'
],
],
];
}
protected function bindNotificationEvents()
{
if (!class_exists(Notifier::class)) {
return;
}
Notifier::bindEvents([
'webmaxx.forms:feedback.sent' => FeedbackFormSentNotifyEvent::class,
]);
}
}