Skip to content

Commit abe88b9

Browse files
authored
Merge pull request #660 from ExpressionEngine/feature/7.x/cli-boot-hook
Added `cli_boot` extension hook to run on each CLI request
2 parents 336678b + 9e84e5f commit abe88b9

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-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: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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)`
17+
18+
| Parameter | Type | Description |
19+
| ------------------ | -------- | ------------------------------------------------------------------------ |
20+
| \$cli | `Object` | Instance of CLI currently running |
21+
| Returns | `Void` | |
22+
23+
Run tasks before every CLI request.
24+
25+
How it's called:
26+
27+
$command = ee()->extensions->call('cli_boot', $this);
28+
if (ee()->extensions->end_script === true) {
29+
$this->complete('');
30+
}
31+
32+
### `cli_before_handle($cli, $commandClass, $command)`
33+
34+
| Parameter | Type | Description |
35+
| -------------- | -------- | ------------------------------------------------------------------------ |
36+
| \$cli | `Object` | Instance of CLI currently running |
37+
| \$commandClass | `String` | Class name of command to be executed |
38+
| \$command | `Object` | Instance of command class to be executed |
39+
| Returns | `Object` | Modified instance of `$command` |
40+
41+
Run tasks right before CLI command is excuted. Allows modification of command class instance.
42+
43+
How it's called:
44+
45+
$command = ee()->extensions->call('cli_before_handle', $this, $commandClass, $command);
46+
if (ee()->extensions->end_script === true) {
47+
$this->complete('');
48+
}

0 commit comments

Comments
 (0)