From 4b07d5bd3bdd74a3e983ee5707f3b05f9e2c6123 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Fri, 18 Apr 2014 16:02:48 -0700 Subject: [PATCH] CRM-14479 - hook_angularModules - Allow specifying multiple *.js files for one module --- CRM/Core/Page/Angular.php | 13 ++++++++++--- CRM/Utils/Hook.php | 1 + 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/CRM/Core/Page/Angular.php b/CRM/Core/Page/Angular.php index 412fc371ab..7b63382b1a 100644 --- a/CRM/Core/Page/Angular.php +++ b/CRM/Core/Page/Angular.php @@ -13,7 +13,11 @@ class CRM_Core_Page_Angular extends CRM_Core_Page { const DEFAULT_MODULE_WEIGHT = 200; function run() { - $res = CRM_Core_Resources::singleton(); + $this->registerResources(CRM_Core_Resources::singleton()); + return parent::run(); + } + + public function registerResources(CRM_Core_Resources $res) { $modules = self::getAngularModules(); $res->addSettingsFactory(function () use (&$modules) { @@ -32,9 +36,12 @@ class CRM_Core_Page_Angular extends CRM_Core_Page { if (!empty($module['file'])) { $res->addScriptFile($module['ext'], $module['file'], self::DEFAULT_MODULE_WEIGHT, 'html-header', TRUE); } + if (!empty($module['files'])) { + foreach ($module['files'] as $file) { + $res->addScriptFile($module['ext'], $file, self::DEFAULT_MODULE_WEIGHT, 'html-header', TRUE); + } + } } - - return parent::run(); } /** diff --git a/CRM/Utils/Hook.php b/CRM/Utils/Hook.php index 664b21a8b1..dd4861fb6f 100644 --- a/CRM/Utils/Hook.php +++ b/CRM/Utils/Hook.php @@ -1611,6 +1611,7 @@ abstract class CRM_Utils_Hook { * @code * function mymod_civicrm_angularModules(&$angularModules) { * $angularModules['myAngularModule'] = array('ext' => 'org.example.mymod', 'file' => 'js/myAngularModule.js'); + * $angularModules['myBigAngularModule'] = array('ext' => 'org.example.mymod', 'files' => array('js/part1.js', 'js/part2.js')); * } * @endcode */ -- 2.25.1