Skip to content

Add hook in ticket parameter to add and change new variables - #20880

Merged
cedric-anne merged 3 commits into
glpi-project:mainfrom
Axel35000-tech:main-add-hook-response-ticket
Mar 17, 2026
Merged

cedric-anne merged 3 commits into
glpi-project:mainfrom
Axel35000-tech:main-add-hook-response-ticket

Conversation

@Axel35000-tech

Copy link
Copy Markdown
Contributor

Checklist before requesting a review

Please delete options that are not relevant.

  • I have read the CONTRIBUTING document.
  • I have performed a self-review of my code.

Description

  • Add hook to add new variables in answers template (followup, solutions, etc.)

@cedric-anne cedric-anne left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi,

Thanks for the contribution.

  1. This should be made in a generic way.

For instance, to get additionnal parameters, you can do something like that in the TemplateDocumentation class, to make the plugin being able to define additional parameters for all the supported object types.

$additionnal_parameters = [];
foreach ($PLUGIN_HOOKS[Hooks::SHOW_ITEM_RESP_PARAM] as $plugin => $hook_callable) {
    $plugin_parameters = Plugin::doOneHook($plugin, Hooks::SHOW_ITEM_RESP_PARAM, $parameters_class::getDefaultNodeName());
    if (is_array($plugin_parameters)) {
        array_push($additionnal_parameters, ...$plugin_parameters);
    }
}
  1. The naming is not correct. These hooks will be used to add additionnal user templates nodes, so something like get_content_template_parameter and get_content_template_value would be more appropriate.

@cedric-anne cedric-anne added this to the 11.1.0 milestone Sep 17, 2025
@Axel35000-tech

Copy link
Copy Markdown
Contributor Author

Hi,

Thanks for the contribution.

  1. This should be made in a generic way.

For instance, to get additionnal parameters, you can do something like that in the TemplateDocumentation class, to make the plugin being able to define additional parameters for all the supported object types.

$additionnal_parameters = [];
foreach ($PLUGIN_HOOKS[Hooks::SHOW_ITEM_RESP_PARAM] as $plugin => $hook_callable) {
    $plugin_parameters = Plugin::doOneHook($plugin, Hooks::SHOW_ITEM_RESP_PARAM, $parameters_class::getDefaultNodeName());
    if (is_array($plugin_parameters)) {
        array_push($additionnal_parameters, ...$plugin_parameters);
    }
}
  1. The naming is not correct. These hooks will be used to add additionnal user templates nodes, so something like get_content_template_parameter and get_content_template_value would be more appropriate.

Hello,
thanks you for your return. Sorry for the delay. I made the change to extend to a generic way.
Please let me know if there are any other changes to be made.

@cedric-anne
cedric-anne force-pushed the main-add-hook-response-ticket branch from f3026a0 to a909c45 Compare March 17, 2026 09:38
@cedric-anne
cedric-anne force-pushed the main-add-hook-response-ticket branch from a909c45 to bb5785d Compare March 17, 2026 09:40
@cedric-anne

Copy link
Copy Markdown
Member

Sorry for the delay.

I rebased your branch to fix conflicts, and added a commit to rename the hook parameters (NodeName -> node_name).

@cedric-anne
cedric-anne merged commit a51ce0a into glpi-project:main Mar 17, 2026
9 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

This PR has been is closed and has been automatically locked. Please open a new issue with all requested information for related bugs.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Jun 26, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants