forked from basic-app/system
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBaseSystemEvents.php
202 lines (153 loc) · 4.88 KB
/
BaseSystemEvents.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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
<?php
/**
* @author Basic App Dev Team <[email protected]>
* @license MIT
* @link http://basic-app.com
*/
namespace BasicApp\System;
use BasicApp\Core\Event;
use BasicApp\System\Events\SystemResetEvent;
use BasicApp\System\Events\SystemSeedEvent;
use BasicApp\System\Config\App\ContentSecurityPolicy;
use BasicApp\System\Config\App\Images;
use BasicApp\System\Config\App\UserAgents;
use BasicApp\System\Config\App\Email;
use BasicApp\System\Config\App\Filters;
use BasicApp\System\Config\App\View;
use BasicApp\System\Config\App\Validation;
use BasicApp\System\Config\App\Pager;
use BasicApp\System\Config\App\Kint;
abstract class BaseSystemEvents extends \CodeIgniter\Events\Events
{
const EVENT_DB_QUERY = 'DBQuery';
const EVENT_PRE_SYSTEM = 'pre_system';
const EVENT_UPDATE = 'ba:update';
const EVENT_SEED = 'ba:seed';
const EVENT_RESET = 'ba:reset';
const EVENT_FILTERS = 'ba:filters';
const EVENT_VIEW = 'ba:view';
const EVENT_IMAGES = 'ba:images';
const EVENT_VALIDATION = 'ba:validation';
const EVENT_EMAIL = 'ba:email';
const EVENT_USER_AGENTS = 'ba:user_agents';
const EVENT_PAGER = 'ba:pager';
const EVENT_CONTENT_SECURITY_POLICY = 'ba:content_security_policy';
const EVENT_KINT = 'ba:kint';
public static function onKint($callback)
{
static::on(static::EVENT_KINT, $callback);
}
public static function onPreSystem($callback)
{
static::on(static::EVENT_PRE_SYSTEM, $callback);
}
public static function onDbQuery($callback)
{
static::on(static::EVENT_DB_QUERY, $callback);
}
public static function onUserAgents($callback)
{
static::on(static::EVENT_USER_AGENTS, $callback);
}
public static function onUpdate($callback)
{
static::on(static::EVENT_UPDATE, $callback);
}
public static function onSeed($callback)
{
static::on(static::EVENT_SEED, $callback);
}
public static function onReset($callback)
{
static::on(static::EVENT_RESET, $callback);
}
public static function onFilters($callback)
{
static::on(static::EVENT_FILTERS, $callback);
}
public static function onView($callback)
{
static::on(static::EVENT_VIEW, $callback);
}
public static function onImages($callback)
{
static::on(static::EVENT_IMAGES, $callback);
}
public static function onValidation($callback)
{
static::on(static::EVENT_VALIDATION, $callback);
}
public static function onPager($callback)
{
static::on(static::EVENT_PAGER, $callback);
}
public static function onEmail($callback)
{
static::on(static::EVENT_EMAIL, $callback);
}
public static function onContentSecurityPolicy($callback)
{
static::on(static::EVENT_CONTENT_SECURITY_POLICY, $callback);
}
public static function update(array $params = [])
{
$event = new Event;
if (array_search('reset', $params) !== false)
{
$event->reset = true;
}
else
{
$event->reset = false;
}
static::trigger(static::EVENT_UPDATE, $event);
}
public static function seed(array $params = [])
{
$event = new SystemSeedEvent;
$event->params = $params;
static::trigger(static::EVENT_SEED, $event);
}
public static function reset(array $params = [])
{
$event = new SystemResetEvent;
$event->params = $params;
static::trigger(static::EVENT_RESET, $event);
}
public static function pager(Pager $pager)
{
static::trigger(static::EVENT_PAGER, $pager);
}
public static function validation(Validation $validation)
{
static::trigger(static::EVENT_VALIDATION, $validation);
}
public static function view(View $view)
{
static::trigger(static::EVENT_VIEW, $view);
}
public static function filters(Filters $filters)
{
static::trigger(static::EVENT_FILTERS, $filters);
}
public static function email(Email $email)
{
static::trigger(static::EVENT_EMAIL, $email);
}
public static function userAgents(UserAgents$userAgents)
{
static::trigger(static::EVENT_USER_AGENTS, $userAgents);
}
public static function images(Images $images)
{
static::trigger(static::EVENT_IMAGES, $images);
}
public static function contentSecurityPolicy(ContentSecurityPolicy $contentSecurityPolicy)
{
static::trigger(static::EVENT_CONTENT_SECURITY_POLICY, $contentSecurityPolicy);
}
public static function kint(Kint $kint)
{
static::trigger(static::EVENT_KINT, $kint);
}
}