|
| 1 | +--- |
| 2 | +lang: php |
| 3 | +--- |
| 4 | + |
| 5 | +<!-- |
| 6 | + This source file is part of the open source project |
| 7 | + ExpressionEngine User Guide (https://github.com/ExpressionEngine/ExpressionEngine-User-Guide) |
| 8 | +
|
| 9 | + @link https://expressionengine.com/ |
| 10 | + @copyright Copyright (c) 2003-2020, Packet Tide, LLC (https://packettide.com) |
| 11 | + @license https://expressionengine.com/license Licensed under Apache License, Version 2.0 |
| 12 | +--> |
| 13 | + |
| 14 | +# CLI Extension Hooks |
| 15 | + |
| 16 | +### `cli_boot($cli, $commandClassName, $commandObject)` |
| 17 | + |
| 18 | +| Parameter | Type | Description | |
| 19 | +| ------------------ | -------- | ------------------------------------------------------------------------ | |
| 20 | +| \$cli | `Object` | Instance of CLI currently running | |
| 21 | +| \$commandClassName | `String` | Class name of command to be executed | |
| 22 | +| \$commandObject | `Object` | Instance of command class to be executed | |
| 23 | +| Returns | `Object` | Modified instance of `$commandObject` | |
| 24 | + |
| 25 | +Run tasks on every CLI request. Allows running the code before certain CLI command is run as well as modification of command class instance. |
| 26 | + |
| 27 | +How it's called: |
| 28 | + |
| 29 | + $command = ee()->extensions->call('cli_boot', $this, $commandClass, $command); |
| 30 | + if (ee()->extensions->end_script === true) { |
| 31 | + $this->complete(''); |
| 32 | + } |
| 33 | + |
| 34 | +### `core_template_route($uri_string)` |
| 35 | + |
| 36 | +| Parameter | Type | Description | |
| 37 | +| ------------ | -------- | ------------------------------------------------------------------------ | |
| 38 | +| \$uri_string | `String` | Current URI string | |
| 39 | +| Returns | `Array` | Array containing the name of the template group and template (see below) | |
| 40 | + |
| 41 | +Reassign the template group and template loaded for parsing. |
| 42 | + |
| 43 | +How it's called: |
| 44 | + |
| 45 | + $edata = ee()->extensions->call('core_template_route', ee()->uri->uri_string); |
| 46 | + if (is_array($edata) && count($edata) == 2) |
| 47 | + { |
| 48 | + list($template_group, $template) = $edata; |
| 49 | + } |
| 50 | + |
| 51 | +Example of array to return: |
| 52 | + |
| 53 | + array( |
| 54 | + 'template_group', // Template group name |
| 55 | + 'template' // Template name |
| 56 | + ); |
0 commit comments