| 1 | <?php |
||
| 33 | abstract class EventableExtensionAbstract extends ExtensionAbstract |
||
| 34 | { |
||
| 35 | /** |
||
| 36 | * Constructor |
||
| 37 | * |
||
| 38 | * @param array $properties |
||
| 39 | * @access public |
||
| 40 | */ |
||
| 41 | public function __construct(array $properties = []) |
||
| 42 | { |
||
| 43 | $this->setProperties($properties); |
||
| 44 | } |
||
| 45 | |||
| 46 | /** |
||
| 47 | * register handlers in the extension with $this->server's evt manager |
||
| 48 | * |
||
| 49 | * {@inheritDoc} |
||
| 50 | */ |
||
| 51 | protected function bootExtension() |
||
| 52 | { |
||
| 53 | foreach ($this->extensionHandles() as $evt) { |
||
| 54 | $this->server->registerEvent($evt['event'], $evt['handler']); |
||
| 55 | } |
||
| 56 | } |
||
| 57 | |||
| 58 | /** |
||
| 59 | * Return event handlers of this extension handling |
||
| 60 | * |
||
| 61 | * ```php |
||
| 62 | * protected function extensionHandles() |
||
| 63 | * { |
||
| 64 | * return [ |
||
| 65 | * ['event' => 'cache.*', 'handler' => ['byPassCache', 100]], |
||
| 66 | * ]; |
||
| 67 | * } |
||
| 68 | * ``` |
||
| 69 | * |
||
| 70 | * @return array |
||
| 71 | * @access protected |
||
| 72 | */ |
||
| 73 | abstract protected function extensionHandles()/*# : array */; |
||
| 74 | } |
||
| 75 |