From b5b34f3c638d5d3207b8cfa3337d8dcdc92ddb75 Mon Sep 17 00:00:00 2001 From: stonebuzz Date: Mon, 16 Sep 2024 16:13:06 +0200 Subject: [PATCH] Feat(core): add exmaple for new hook (pre/post_item_accordion_section) --- setup.php | 3 +++ src/ItemForm.php | 68 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+) diff --git a/setup.php b/setup.php index 8c61150..8848947 100644 --- a/setup.php +++ b/setup.php @@ -235,6 +235,9 @@ function plugin_init_example() { $PLUGIN_HOOKS[Hooks::PRE_ITEM_FORM]['example'] = [ItemForm::class, 'preItemForm']; $PLUGIN_HOOKS[Hooks::POST_ITEM_FORM]['example'] = [ItemForm::class, 'postItemForm']; + $PLUGIN_HOOKS[Hooks::PRE_SECTION]['example'] = [ItemForm::class, 'preSection']; + $PLUGIN_HOOKS[Hooks::POST_SECTION]['example'] = [ItemForm::class, 'postSection']; + // Add new actions to timeline $PLUGIN_HOOKS[Hooks::TIMELINE_ACTIONS]['example'] = [ ItemForm::class, 'timelineActions' diff --git a/src/ItemForm.php b/src/ItemForm.php index 3920135..a6b882f 100644 --- a/src/ItemForm.php +++ b/src/ItemForm.php @@ -29,6 +29,8 @@ */ namespace GlpiPlugin\Example; + +use Glpi\Application\View\TemplateRenderer; use Html; use Ticket; @@ -39,6 +41,72 @@ use Ticket; * */ class ItemForm { + + /** + * Display contents at the begining of ITILObject section (right panel). + * + * @param array $params Array with "item" and "options" keys + * + * @return void + */ + static public function preSection($params) { + $item = $params['item']; + $options = $params['options']; + + echo TemplateRenderer::getInstance()->renderFromStringTemplate(<< +

+ +

+
+
+ Example pre section +
+
+ +TWIG, []); + + } + + /** + * Display contents at the end of ITILObject section (right panel). + * + * @param array $params Array with "item" and "options" keys + * + * @return void + */ + static public function postSection($params) { + $item = $params['item']; + $options = $params['options']; + + echo TemplateRenderer::getInstance()->renderFromStringTemplate(<< +

+ +

+
+
+ Example post section +
+
+ +TWIG, []); + } + + + + + /** * Display contents at the begining of item forms. *