Closed (duplicate)
Project:
Drupal core
Version:
11.x-dev
Component:
plugin system
Priority:
Minor
Category:
Feature request
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
29 Jan 2018 at 21:39 UTC
Updated:
18 Oct 2024 at 15:23 UTC
Jump to comment: Most recent
Comments
Comment #2
olexyy.mails@gmail.com commentedThat would be the first step to deprecating static calls of services. As for manager itself, I see two approaches.
First: each plugin could have machine name according to hook naming convention and only one method to be called. So plugin would be picked up by machine name. In result each hook would have one file.
Second approach to have this method not for implementation, but for information of hooks implementation, so several hooks could be implemented in one plugin.
Comment #3
cilefen commentedHi! This is an interesting idea however it seems to be duplicating existing efforts.
Comment #4
olexyy.mails@gmail.com commentedHere we can discuss plugins implementation, other issues about tagged service and events.
Comment #5
olexyy.mails@gmail.com commentedI've just started basic implementation as contrib by altering module_handler service.
Current implementation has some advantages:
- it should be rather fast;
- it uses caching and static;
- priority is supported;
- we have progress in naming convention problems;
- we can inject services to classes that implement hooks;
Repo:
https://github.com/Olexyy/hook_manager.git
If there are any thoughts, please share.
Comment #6
olexyy.mails@gmail.com commentedRelated working project.
https://www.drupal.org/sandbox/olexyymailsgmailcom/hook_manager
There is now added 'static' map for alter hooks, changed priority logic.
This can be merged with core, if in general is ok and performance is enough.
Comment #7
olexyy.mails@gmail.com commentedThe idea is rather simple:
Annotation to plugin contains list of canonical names for hooks with corresponding priority. (f.e. hook_theme => 0)
We need to implement this hook as method in camel case, so this is public function hookTheme();
Comment #18
catchDuplicate of #3442009: OOP hooks using attributes and event dispatcher