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() |
||
107 | |||
108 | /** |
||
109 | * Returns the target application language. |
||
110 | * |
||
111 | * @return string |
||
112 | */ |
||
113 | public function getLanguage() |
||
117 | |||
118 | /** |
||
119 | * Sets the target application language. |
||
120 | * |
||
121 | * @param string $language |
||
122 | */ |
||
123 | public function setLanguage($language) |
||
127 | |||
128 | /** |
||
129 | * Returns the system time zone. Note that this method cannot be in {@link AppBehavior}, because Yii will check |
||
130 | * {@link \CApplication::getTimeZone()} instead. |
||
131 | * |
||
132 | * @return string |
||
133 | */ |
||
134 | public function getTimeZone() |
||
138 | |||
139 | /** |
||
140 | * Attaches an event handler, or remembers it for later if the component has not been initialized yet. |
||
141 | * |
||
142 | * The event should be identified in a `serviceHandle.eventName` format. For example, if you want to add an event |
||
143 | * handler for {@link EntriesService::onSaveEntry()}, you would do this: |
||
144 | * |
||
145 | * ```php |
||
146 | * Craft::app()->on('entries.saveEntry', function(Event $event) { |
||
147 | * // ... |
||
148 | * }); |
||
149 | * ``` |
||
150 | * |
||
151 | * Note that the actual event name (`saveEntry`) does not need to include the “`on`”. |
||
152 | * |
||
153 | * By default, event handlers will not get attached if Craft is current in the middle of updating itself or a |
||
154 | * plugin. If you want the event to fire even in that condition, pass `true` to the $evenDuringUpdates argument. |
||
155 | * |
||
156 | * @param string $event The event to listen for |
||
157 | * @param mixed $handler The event handler |
||
158 | */ |
||
159 | public function on($event, $handler) |
||
176 | |||
177 | /** |
||
178 | * Returns whether we are executing in the context on a console app. |
||
179 | * |
||
180 | * @return bool |
||
181 | */ |
||
182 | public function isConsole() |
||
186 | |||
187 | /** |
||
188 | * Returns the target application theme. |
||
189 | * |
||
190 | * @return string |
||
191 | */ |
||
192 | public function getTheme() |
||
196 | |||
197 | |||
198 | /** |
||
199 | * Override getComponent() so we can attach any pending events if the component is getting initialized as well as |
||
200 | * do some special logic around creating the `Craft::app()->db` application component. |
||
201 | * |
||
202 | * @param string $id |
||
203 | * @param bool $createIfNull |
||
204 | * |
||
205 | * @return mixed |
||
206 | */ |
||
207 | public function getComponent($id, $createIfNull = true) |
||
223 | |||
224 | /** |
||
225 | * Sets the application components. |
||
226 | * |
||
227 | * @param $components |
||
228 | * @param bool $merge |
||
229 | */ |
||
230 | public function setComponents($components, $merge = true) |
||
239 | |||
240 | /** |
||
241 | * @todo Remove for Craft 3 |
||
242 | * |
||
243 | * @param int $code The level of the error raised |
||
244 | * @param string $message The error message |
||
245 | * @param string $file The filename that the error was raised in |
||
246 | * @param int $line The line number the error was raised at |
||
247 | */ |
||
248 | public function handleError($code, $message, $file, $line) |
||
260 | |||
261 | // Protected Methods |
||
262 | // ========================================================================= |
||
263 | |||
264 | /** |
||
265 | * @return ConsoleCommandRunner |
||
266 | */ |
||
267 | protected function createCommandRunner() |
||
271 | |||
272 | // Private Methods |
||
273 | // ========================================================================= |
||
274 | |||
275 | /** |
||
276 | * Attaches any pending event listeners to the newly-initialized component. |
||
277 | * |
||
278 | * @param string $componentId |
||
279 | */ |
||
280 | private function _attachEventListeners($componentId) |
||
294 | |||
295 | /** |
||
296 | * Sets the edition components. |
||
297 | */ |
||
298 | private function _setEditionComponents() |
||
311 | |||
312 | /** |
||
313 | * Sets the schematic components. |
||
314 | */ |
||
315 | private function _setSchematicComponents() |
||
368 | |||
369 | /** |
||
370 | * Install Craft. |
||
371 | */ |
||
372 | private function _installCraft() |
||
385 | } |
||
386 |