summaryrefslogtreecommitdiff
path: root/app/Core/Plugin/Base.php
blob: 580d41ad41984375ffbd485268a351652b24eb0d (plain)
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
<?php

namespace Core\Plugin;

/**
 * Plugin Base class
 *
 * @package  plugin
 * @author   Frederic Guillot
 */
abstract class Base extends \Core\Base
{
    /**
     * Method called for each request
     *
     * @abstract
     * @access public
     */
    abstract public function initialize();

    /**
     * Returns all classes that needs to be stored in the DI container
     *
     * @access public
     * @return array
     */
    public function getClasses()
    {
        return array();
    }

    /**
     * Listen on internal events
     *
     * @access public
     * @param  string   $event
     * @param  callable $callback
     */
    public function on($event, $callback)
    {
        $container = $this->container;

        $this->container['dispatcher']->addListener($event, function() use ($container, $callback) {
            call_user_func($callback, $container);
        });
    }
}