Skip to content

Commit

Permalink
Merge pull request civicrm#11171 from mydropwizard/drupal-8-hooks
Browse files Browse the repository at this point in the history
CRM-21341 Drupal 8 Hook Support
  • Loading branch information
jackrabbithanna authored and sluc23 committed Jan 10, 2018
2 parents 70bf8b3 + c6cdd76 commit 62210cc
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
9 changes: 9 additions & 0 deletions CRM/Utils/Hook/Drupal8.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,13 @@
*/
class CRM_Utils_Hook_Drupal8 extends CRM_Utils_Hook_DrupalBase {

/**
* {@inheritdoc}
*/
protected function getDrupalModules() {
if (class_exists('\Drupal') && \Drupal::hasContainer()) {
return array_keys(\Drupal::moduleHandler()->getModuleList());
}
}

}
19 changes: 15 additions & 4 deletions CRM/Utils/Hook/DrupalBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,7 @@ public function invokeViaUF(
public function buildModuleList() {
if ($this->isBuilt === FALSE) {
if ($this->drupalModules === NULL) {
if (function_exists('module_list')) {
// copied from user_module_invoke
$this->drupalModules = module_list();
}
$this->drupalModules = $this->getDrupalModules();
}

if ($this->civiModules === NULL) {
Expand Down Expand Up @@ -128,4 +125,18 @@ public function buildModuleList() {
}
}

/**
* Gets modules installed on the Drupal site.
*
* @return array|null
* The machine names of the modules installed in Drupal, or NULL if unable
* to determine the modules.
*/
protected function getDrupalModules() {
if (function_exists('module_list')) {
// copied from user_module_invoke
return module_list();
}
}

}

0 comments on commit 62210cc

Please sign in to comment.