Skip to content
Snippets Groups Projects
Commit d3896e38 authored by rakugaki's avatar rakugaki Committed by Eleo Basili
Browse files

Issue #3499572 by rakugaki: make request_body available in hook_post_execute

parent afaea788
No related branches found
No related tags found
1 merge request!44Resolve #3499572 "Make request body available in hook post execute"
Pipeline #546653 passed with warnings
......@@ -53,19 +53,20 @@ function mymodule_pre_execute(array &$request_body) {
}
```
### 2. `hook_post_execute(array &$result)`
### 2. `hook_post_execute(array &$result, array &$request_body)`
This hook is invoked after the augmentor execution is completed. It allows other modules to alter the results of the execution.
#### Parameters:
- `$result` (array): The results of the augmentor execution. It is an associative array of the results.
- `$request_body` (array): The decoded request body. It is an associative array that contains the keys 'input' and 'augmentor'.
#### Usage:
Implement this hook to modify the results after the augmentor execution. For example, you can process or reformat the results as needed.
Example:
```php
function mymodule_post_execute(array &$result) {
function mymodule_post_execute(array &$result, array &$request_body) {
// Process or alter the results.
if (!empty($result)) {
$result['additional_info'] = "Processed Result";
......
......@@ -19,6 +19,8 @@ function hook_pre_execute(array &$decoded_request_body) {
*
* @param array $results
* The results of the augmentor execution.
* @param array $decoded_request_body
* The decoded request body.
*/
function hook_post_execute(array &$result) {
function hook_post_execute(array &$result, array &$decoded_request_body) {
}
......@@ -91,7 +91,7 @@ class AugmentorController extends ControllerBase implements ContainerInjectionIn
$decoded_request_body['input']
);
// Call Post Execure hooks to alter the results.
$this->moduleHandler->invokeAll('post_execute', [&$result]);
$this->moduleHandler->invokeAll('post_execute', [&$result, &$decoded_request_body]);
}
catch (\Throwable $error) {
$result = ['_errors' => $error->getMessage()];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment