Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
augmentor
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
augmentor
Commits
d3896e38
Commit
d3896e38
authored
6 months ago
by
rakugaki
Committed by
Eleo Basili
6 months ago
Browse files
Options
Downloads
Patches
Plain Diff
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
!44
Resolve #3499572 "Make request body available in hook post execute"
Pipeline
#546653
passed with warnings
2 months ago
Stage: build
Stage: validate
Changes
3
Pipelines
2
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
README.md
+4
-3
4 additions, 3 deletions
README.md
augmentor.api.php
+3
-1
3 additions, 1 deletion
augmentor.api.php
src/Controller/AugmentorController.php
+1
-1
1 addition, 1 deletion
src/Controller/AugmentorController.php
with
8 additions
and
5 deletions
README.md
+
4
−
3
View file @
d3896e38
...
...
@@ -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"
;
...
...
This diff is collapsed.
Click to expand it.
augmentor.api.php
+
3
−
1
View file @
d3896e38
...
...
@@ -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
)
{
}
This diff is collapsed.
Click to expand it.
src/Controller/AugmentorController.php
+
1
−
1
View file @
d3896e38
...
...
@@ -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
()];
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
sign in
to comment