1 | <?php |
||
22 | class App extends Base |
||
23 | { |
||
24 | // Properties |
||
25 | // ========================================================================= |
||
26 | |||
27 | /** |
||
28 | * @var |
||
29 | */ |
||
30 | public $componentAliases; |
||
31 | |||
32 | /** |
||
33 | * @var |
||
34 | */ |
||
35 | private $_pendingEvents; |
||
36 | |||
37 | /** |
||
38 | * @var |
||
39 | */ |
||
40 | private $_editionComponents; |
||
41 | |||
42 | // Public Methods |
||
43 | // ========================================================================= |
||
44 | |||
45 | /** |
||
46 | * Initializes the console app by creating the command runner. |
||
47 | */ |
||
48 | public function init() |
||
102 | |||
103 | /** |
||
104 | * Returns the target application language. |
||
105 | * |
||
106 | * @return string |
||
107 | */ |
||
108 | public function getLanguage() |
||
112 | |||
113 | /** |
||
114 | * Sets the target application language. |
||
115 | * |
||
116 | * @param string $language |
||
117 | */ |
||
118 | public function setLanguage($language) |
||
122 | |||
123 | /** |
||
124 | * Returns the system time zone. Note that this method cannot be in {@link AppBehavior}, because Yii will check |
||
125 | * {@link \CApplication::getTimeZone()} instead. |
||
126 | * |
||
127 | * @return string |
||
128 | */ |
||
129 | public function getTimeZone() |
||
133 | |||
134 | /** |
||
135 | * Attaches an event handler, or remembers it for later if the component has not been initialized yet. |
||
136 | * |
||
137 | * The event should be identified in a `serviceHandle.eventName` format. For example, if you want to add an event |
||
138 | * handler for {@link EntriesService::onSaveEntry()}, you would do this: |
||
139 | * |
||
140 | * ```php |
||
141 | * Craft::app()->on('entries.saveEntry', function(Event $event) { |
||
142 | * // ... |
||
143 | * }); |
||
144 | * ``` |
||
145 | * |
||
146 | * Note that the actual event name (`saveEntry`) does not need to include the “`on`”. |
||
147 | * |
||
148 | * By default, event handlers will not get attached if Craft is current in the middle of updating itself or a |
||
149 | * plugin. If you want the event to fire even in that condition, pass `true` to the $evenDuringUpdates argument. |
||
150 | * |
||
151 | * @param string $event The event to listen for. |
||
152 | * @param mixed $handler The event handler. |
||
153 | */ |
||
154 | public function on($event, $handler) |
||
167 | |||
168 | /** |
||
169 | * Returns whether we are executing in the context on a console app. |
||
170 | * |
||
171 | * @return bool |
||
172 | */ |
||
173 | public function isConsole() |
||
177 | |||
178 | /** |
||
179 | * Override getComponent() so we can attach any pending events if the component is getting initialized as well as |
||
180 | * do some special logic around creating the `Craft::app()->db` application component. |
||
181 | * |
||
182 | * @param string $id |
||
183 | * @param bool $createIfNull |
||
184 | * |
||
185 | * @return mixed |
||
186 | */ |
||
187 | public function getComponent($id, $createIfNull = true) |
||
203 | |||
204 | /** |
||
205 | * Sets the application components. |
||
206 | * |
||
207 | * @param $components |
||
208 | * @param bool $merge |
||
209 | */ |
||
210 | public function setComponents($components, $merge = true) |
||
219 | |||
220 | /** |
||
221 | * @todo Remove for Craft 3. |
||
222 | * |
||
223 | * @param int $code The level of the error raised. |
||
224 | * @param string $message The error message. |
||
225 | * @param string $file The filename that the error was raised in. |
||
226 | * @param int $line The line number the error was raised at. |
||
227 | */ |
||
228 | public function handleError($code, $message, $file, $line) |
||
240 | |||
241 | // Protected Methods |
||
242 | // ========================================================================= |
||
243 | |||
244 | /** |
||
245 | * @return ConsoleCommandRunner |
||
246 | */ |
||
247 | protected function createCommandRunner() |
||
251 | |||
252 | // Private Methods |
||
253 | // ========================================================================= |
||
254 | |||
255 | /** |
||
256 | * Attaches any pending event listeners to the newly-initialized component. |
||
257 | * |
||
258 | * @param string $componentId |
||
259 | */ |
||
260 | private function _attachEventListeners($componentId) |
||
274 | |||
275 | /** |
||
276 | * Sets the edition components. |
||
277 | */ |
||
278 | private function _setEditionComponents() |
||
291 | |||
292 | /** |
||
293 | * Sets the schematic components. |
||
294 | */ |
||
295 | private function _setSchematicComponents() |
||
342 | |||
343 | /** |
||
344 | * Install Craft. |
||
345 | */ |
||
346 | private function _installCraft() |
||
359 | } |
||
360 |