Skip to content

Commit 9787367

Browse files
committed
Added cli_boot extension hook to run on each CLI request
1 parent c0d7a54 commit 9787367

File tree

2 files changed

+57
-0
lines changed

2 files changed

+57
-0
lines changed

docs/development/extension-hooks/extension-hooks-overview.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ TIP: Reference [Extending The Core](development/extensions.md) for more informat
2020
Core hooks are categorized into 5 categories:
2121
- Global
2222
- [Core Library](development/extension-hooks/global/core.md)
23+
- [CLI](development/extension-hooks/global/cli.md)
2324
- [Email Library](development/extension-hooks/global/email.md)
2425
- [Filemanager Library](development/extension-hooks/global/filemanager.md)
2526
- [Functions Library](development/extension-hooks/global/functions.md)
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
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

Comments
 (0)