-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathPluginHandler.php
More file actions
36 lines (29 loc) · 884 Bytes
/
Copy pathPluginHandler.php
File metadata and controls
36 lines (29 loc) · 884 Bytes
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
<?php
namespace Example;
class PluginHandler
{
/**
* @var Zend\EventManager\EventManager
*/
protected $eventManager = null;
public function __construct()
{
$this->eventManager = new \Zend\EventManager\EventManager();
}
public function register($plugin)
{
if (method_exists($plugin, 'onInit')) {
$this->eventManager->attach('init', array($plugin, 'onInit'));
}
if (method_exists($plugin, 'onPreDispatch')) {
$this->eventManager->attach('preDispatch', array($plugin, 'onPreDispatch'));
}
if (method_exists($plugin, 'onPostDispatch')) {
$this->eventManager->attach('postDispatch', array($plugin, 'onPostDispatch'));
}
}
public function notify($event)
{
$this->eventManager->trigger($event, $this);
}
}