1 | <?php |
||
14 | class ExternalModule extends Module implements iExternalModule |
||
15 | { |
||
16 | /** @var Module Pointer to parent module */ |
||
17 | public $parent = null; |
||
18 | |||
19 | /** |
||
20 | * ExternalModule constructor. |
||
21 | * |
||
22 | * @param string $path |
||
23 | * @param ResourcesInterface $resources |
||
24 | * @param SystemInterface $system |
||
25 | */ |
||
26 | public function __construct($path, ResourcesInterface $resources, SystemInterface $system) |
||
27 | { |
||
28 | // Module identifier not specified - set it to NameSpace\Classname |
||
29 | if (!isset($this->id{0})) { |
||
30 | // Generate identifier from module class |
||
31 | $this->id = strtolower(str_replace(__NS_SEPARATOR__, '_', get_class($this))); |
||
32 | } |
||
33 | |||
34 | // Subscribe to an config ready core event |
||
35 | Event::subscribe('core.started', array(& $this, 'init')); |
||
36 | |||
37 | // Call parent constructor |
||
38 | parent::__construct($this->id, $path, $resources, $system); |
||
39 | } |
||
40 | |||
41 | /** @see \samson\core\iExternalModule::copy() */ |
||
42 | public function ©() |
||
43 | { |
||
44 | // Get current class name |
||
45 | $classname = get_class($this); |
||
46 | |||
47 | // Create copy instance |
||
48 | $clone = new $classname($this->path, $this->resourceMap, $this->system); |
||
49 | $clone->views = &$this->views; |
||
50 | $clone->parent = &$this->parent; |
||
51 | $clone->path = $this->path; |
||
52 | |||
53 | return $clone; |
||
54 | } |
||
55 | |||
56 | /** Обработчик сериализации объекта */ |
||
57 | public function __sleep() |
||
62 | |||
63 | |||
64 | /** |
||
65 | * Set current view for rendering. |
||
66 | * |
||
67 | * @param string $viewPath Path for view searching |
||
68 | * @return self Chaining |
||
69 | */ |
||
70 | public function view($viewPath) |
||
98 | |||
99 | /** |
||
100 | * Overloading default module rendering behaviour |
||
101 | * as it is used in templates and views using m()->render() |
||
102 | * without specifying concrete module or passing a variable. |
||
103 | * |
||
104 | * @param string $controller Controller action name |
||
105 | */ |
||
106 | public function render($controller = null) |
||
120 | |||
121 | public function setId($id) |
||
125 | |||
126 | /** |
||
127 | * Module preparation handler. |
||
128 | * This function is triggered after module instance is being created. |
||
129 | * |
||
130 | * @return bool Preparation result |
||
131 | */ |
||
132 | public function prepare() |
||
136 | |||
137 | /** |
||
138 | * Module initialization. |
||
139 | * This function is triggered when system has started. So here |
||
140 | * we have all modules already prepared and loaded. |
||
141 | * |
||
142 | * @param array $params Collection of module initialization parameters |
||
143 | * @return bool Initialization result |
||
144 | */ |
||
145 | public function init(array $params = array()) |
||
151 | } |
||
152 |