See this change record: Core added support for OOP hook implementations, support for procedural hooks (with magic names) is expected to be phased out mid-term. There is already a proposed way of making this switch without depending on Drupal 11.1 so we can implement this any time we want.
This will be especially nice for us as we are currently mixing different concerns, namely framework code plus code for specific plugins, in hook implementations. Now, we can just have two implementations.
As most of the actual code for hook implementations was already moved to classes, it also seems like we might just need to move them to the new location (\Drupal\search_api\Hook) – keeping BC in mind, of course.
Issue fork search_api-3489482
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
sayan_k_dutta commentedWorking on it.
Comment #8
sayan_k_dutta commentedWorking further to convert the views_hooks in oop implementation.
Comment #9
sayan_k_dutta commentedMade the changes. Please review MR !218
Comment #10
drunken monkeyThanks a lot for your work on this, great job so far! However, there are still a couple of problems, as evidenced by the failing tests:
SearchApiViewHooksis missing aservices.ymlentry.SearchApiViewsHooks, as the module name is “Views”.)autowireyet, but I just temporarily enabled testing against other Drupal versions in the fork to validate that assumption.Hooksclasses should be accessed via dependency injection (which is also whyautowirewould even be needed, I think), not via the global\Drupalclass. As a rule, classes that are able to use dependency injection should not contain the string'\Drupal::'.I already implemented the first two items, but please address the last one as well as the failing MR pipelines.
Comment #11
drunken monkeyWas quite a bit of work to add proper DI and get everything properly organized but I think this is now ready to be reviewed.
Comment #12
drunken monkeyI think the pipelines should pass now except for “next minor” which currently fails in HEAD as well, see #3553016: Fix pipelines for Drupal 10 and Drupal 11.3.x.
Let’s see.
Comment #13
drunken monkeyMerged.
Thanks a lot again for your help on this!