Skip to content

Commit

Permalink
Rename timeline items hook (#18758)
Browse files Browse the repository at this point in the history
* rename timeline items hook

* readd old constant

* restore old name

* Add deprecation

---------

Co-authored-by: Cédric Anne <[email protected]>
  • Loading branch information
cconard96 and cedric-anne authored Jan 27, 2025
1 parent 962ae5d commit cde67f0
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ The present file will list all changes made to the project; according to the
- `Search::getOptions()` no longer returns a reference.
- The `$target` parameter has been removed from the `AuthLDAP::showLdapGroups()` method.
- The `$target` parameter has been removed from the `Rule::showRulePreviewCriteriasForm()`, `Rule::showRulePreviewResultsForm()`, `RuleCollection::showRulesEnginePreviewCriteriasForm()`, and `RuleCollection::showRulesEnginePreviewResultsForm()` methods signature.
- `Hooks::SHOW_IN_TIMELINE`/`show_in_timeline` plugin hook has been renamed to `Hooks::TIMELINE_ITEMS`/`timeline_items`.

#### Deprecated
- Usage of the `/marketplace` path for plugins URLs. All plugins URLs should now start with `/plugins`.
Expand Down
3 changes: 2 additions & 1 deletion src/CommonITILObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -7888,7 +7888,8 @@ class_exists($validation_class) && $params['with_validations']
];
}

Plugin::doHook(Hooks::SHOW_IN_TIMELINE, ['item' => $this, 'timeline' => &$timeline]);
Plugin::doHook(Hooks::SHOW_IN_TIMELINE, ['item' => $this, 'timeline' => &$timeline]); // @phpstan-ignore classConstant.deprecated
Plugin::doHook(Hooks::TIMELINE_ITEMS, ['item' => $this, 'timeline' => &$timeline]);

//sort timeline items by date. If items have the same date, sort by id
$reverse = $params['sort_by_date_desc'];
Expand Down
6 changes: 5 additions & 1 deletion src/Glpi/Plugin/Hooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,11 @@ class Hooks
const PRE_ITEM_LIST = 'pre_item_list';
const TIMELINE_ACTIONS = 'timeline_actions'; // (keys: item, rand)
const TIMELINE_ANSWER_ACTIONS = 'timeline_answer_actions'; // (keys: item)
const SHOW_IN_TIMELINE = 'show_in_timeline'; // (keys: item)
/**
* @deprecated 11.0.0 Use `TIMELINE_ITEMS` instead.
*/
const SHOW_IN_TIMELINE = 'show_in_timeline';
const TIMELINE_ITEMS = 'timeline_items'; // (keys: item)
const SET_ITEM_IMPACT_ICON = 'set_item_impact_icon'; // (keys: itemtype, items_id)

// Security hooks (data to encypt)
Expand Down
4 changes: 4 additions & 0 deletions src/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -1537,6 +1537,10 @@ public static function doHook($name, $param = null)
continue;
}

if ($name === Hooks::SHOW_IN_TIMELINE) { // @phpstan-ignore classConstant.deprecated
Toolbox::deprecated('`show_in_timeline` hook is deprecated, use `timeline_items` instead.');
}

if (isset($tab[$itemtype])) {
\Glpi\Debug\Profiler::getInstance()->start("{$plugin_key}:{$name}", \Glpi\Debug\Profiler::CATEGORY_PLUGINS);
self::includeHook($plugin_key);
Expand Down

0 comments on commit cde67f0

Please sign in to comment.