-
-
Notifications
You must be signed in to change notification settings - Fork 814
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CRM-21341 Drupal 8 Hook Support #11171
Conversation
Can one of the admins verify this patch? |
ooh yeah, I'll test this out this weekend, awesome :) |
@jackrabbithanna I was also looking into supporting event subscribers, which are now utilized in Drupal as of D8. I'm not seeing anything in any of the CMSs' integration that looks to provide this. Is there anything you may be able to point me towards? |
Jenkins ok to test |
Created JIRA ticket for this PR |
I've confirmed this PR works, I created a small test module that implements hook_civicrm_post() and write a log entry to the dlog.... |
@kerasai We may want to keep this PR to adding hook support, and perhaps create another JIRA issue for event subscribers. As a standard practice it is recommended to create JIRA issues at https://issues.civicrm.org ... I've been adding the label 'drupal8' to issues that are for Drupal 8 development. If you don't have access to create issues in JIRA or need help, ping me on https://chat.civicrm.org , infrastructure channel, and I can help or point you to somebody that can help.... Then we can have a separate discussion about the event subscribers on the JIRA ticket, and this PR can get merged and others get the functionality while discussions take place. @colemanw or @totten , I've reviewed the code and verified functionality. Good to merge in my opinion. |
@jackrabbithanna, I agree--the work/discussion for the event subscribers should be split off to another PR/issue in order to get this work for the traditional "hooks" in. I don't have access to the JIRA site, have been waiting on approval for a few weeks now. I'd be glad to create an issue there, and document a plan for implementation. |
A couple things...
|
@totten agree with you on all parts, I think the reason between module_invoke_all and module_list is that we are trying to get a list of modules and combine that with a list of extensions so that when we invoke the hook we invoke for all at once perhaps? |
CRM/Utils/Hook/Drupal8.php
Outdated
* {@inheritdoc} | ||
*/ | ||
protected function getDrupalModules() { | ||
if (class_exists('\Drupal')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be changed to:
if (class_exists('\Drupal') && \Drupal::hasContainer()) {
Otherwise, I'm seeing this line crash when running 'cv' on a Drupal 8 site because this gets called before 'cv' has a chance to bootstrap Drupal
I pushed a new commit to fix the issue I commented about :-) |
@jackrabbithanna Sorry, I'm not involved in this project, so I'm unable to comment on or give my blessing to @dsnopek 's change. Perhaps you meant someone else. |
ok sorry, 14 days ago you said it was ok, the change is an improvement on what already worked |
@jackrabbithanna different users, nearly identical usernames. A new type of off by one error ;) |
Oh I see now...there are multiple totten(s) :) ? |
@jackrabbithanna I need to find out who is this doppelganger of mine! :) |
CRM-21341 Drupal 8 Hook Support
Overview
This PR adds support for calling CiviCRM hooks provided by Drupal modules in a Drupal 8 installation.
Before
Code for CiviCRM hooks provided by Drupal 8 modules never gets called.
After
Code for CiviCRM hooks provided by Drupal 8 modules now gets called after adding the appropriate code to make CiviCRM aware of the Drupal 8 modules.
Technical Details
I've refactored
\CRM_Utils_Hook_DrupalBase
to include a::getDrupalModules
method that calls the existing Drupal code for obtaining the module list. Then I built out\CRM_Utils_Hook_Drupal8
class to override the method with the Drupal 8 equivalent code for obtaining the list of modules.