forked from abwebdevelopers/oc-forms-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlugin.php
More file actions
77 lines (68 loc) · 2.21 KB
/
Plugin.php
File metadata and controls
77 lines (68 loc) · 2.21 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
<?php namespace ABWebDevelopers\Forms;
use System\Classes\PluginBase;
use ABWebDevelopers\Forms\Models\Settings;
use Event;
class Plugin extends PluginBase
{
/**
* @var string Event namespace
*/
public const EVENTS_PREFIX = 'abweb.forms.';
/**
* Register Plugin Components
*
* @return array
*/
public function registerComponents()
{
return [
'ABWebDevelopers\Forms\Components\CustomForm' => 'customForm'
];
}
/**
* Register Plugin Settings
*
* @return array
*/
public function registerSettings() {
return [
'settings' => [
'label' => 'Custom Forms',
'description' => 'Simple multipurpose form builder',
'category' => 'Small plugins',
'icon' => 'icon-inbox',
'class' => 'ABWebDevelopers\Forms\Models\Settings',
'keywords' => 'form custom contact abweb recaptcha antispam',
'order' => 555,
'permissions' => ['abwebdevelopers.forms.access_settings'],
]
];
}
/**
* Register Plugin Mail Templates
*
* @return array
*/
public function registerMailTemplates()
{
return [
'abwebdevelopers.forms::mail.autoreply' => 'abwebdevelopers.forms::lang.mail.templates.autoreply',
'abwebdevelopers.forms::mail.notification' => 'abwebdevelopers.forms::lang.mail.templates.notification',
];
}
/**
* Inject patch JS and CSS when creating/updating forms
*/
public function boot() {
Event::listen('backend.page.beforeDisplay', function ($controller, $action, $params) {
if ($controller instanceof \ABWebDevelopers\Forms\Controllers\Form) {
// Check this is the settings page for this plugin:
if ($action === 'update' || $action === 'create') {
// Add CSS (minor patch)
$controller->addCss('/plugins/abwebdevelopers/forms/assets/settings-patch.css');
$controller->addJs('/plugins/abwebdevelopers/forms/assets/settings-patch.js');
}
}
});
}
}