Skip to content

Commit

Permalink
add explanations
Browse files Browse the repository at this point in the history
  • Loading branch information
matthieu-rolland committed Nov 12, 2024
1 parent 078b075 commit 6039dcd
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/Core/Hook/HookModuleFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,18 @@

namespace PrestaShop\PrestaShop\Core\Hook;

/**
* This service is responsible for filtering the list of modules for a given hook that is returned by
* the getHookModuleExecList method from Hook.php. It is called at the very end of getHookModuleExecList.
*
* How to use it to filter a list of modules for a hook:
*
* In your module, create a service which implements the HookModuleFilterInterface and give it
* the tag named core.hook_module_exec_filter. Then in your service, you can filter the list of modules
* in the filterHookModuleExecList method, according to your own logic.
*
* Your service will automatically be sent in this class's constructor, and be used to filter the list of modules.
*/
class HookModuleFilter implements HookModuleFilterInterface
{
private $hookModuleFilters;
Expand Down
4 changes: 4 additions & 0 deletions src/Core/Hook/HookModuleFilterInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@

namespace PrestaShop\PrestaShop\Core\Hook;

/**
* This interface must be implemented by all services that will be used by the HookModuleFilter service.
* See HookModuleFilter.php for more explanations.
*/
interface HookModuleFilterInterface
{
public function filterHookModuleExecList(array $modules, string $hookName): array;
Expand Down

0 comments on commit 6039dcd

Please sign in to comment.