Set version to 4.7.25
[civicrm-core.git] / CRM / Utils / Hook.php
index 23e29ef595ca63d76697b9c01406dba8dcb1e183..1484a1fdaf525662e77a01bc0daae504bc651d87 100644 (file)
@@ -207,10 +207,11 @@ abstract class CRM_Utils_Hook {
       $this->commonIncluded = TRUE;
 
       $config = CRM_Core_Config::singleton();
-      if (!empty($config->customPHPPathDir) &&
-        file_exists("{$config->customPHPPathDir}/civicrmHooks.php")
-      ) {
-        @include_once "civicrmHooks.php";
+      if (!empty($config->customPHPPathDir)) {
+        $civicrmHooksFile = CRM_Utils_File::addTrailingSlash($config->customPHPPathDir) . 'civicrmHooks.php';
+        if (file_exists($civicrmHooksFile)) {
+          @include_once $civicrmHooksFile;
+        }
       }
 
       if (!empty($fnPrefix)) {
@@ -2071,6 +2072,19 @@ abstract class CRM_Utils_Hook {
     );
   }
 
+  /**
+   * Modify the CRM_Core_Resources settings data.
+   *
+   * @param array $data
+   * @see CRM_Core_Resources::addSetting
+   */
+  public static function alterResourceSettings(&$data) {
+    $event = \Civi\Core\Event\GenericHookEvent::create(array(
+      'data' => &$data,
+    ));
+    Civi::dispatcher()->dispatch('hook_civicrm_alterResourceSettings', $event);
+  }
+
   /**
    * EXPERIMENTAL: This hook allows one to register additional Angular modules
    *
@@ -2081,6 +2095,10 @@ abstract class CRM_Utils_Hook {
    *    - css: array, list of CSS files or globs.
    *    - partials: array, list of base-dirs containing HTML.
    *    - requires: array, list of required Angular modules.
+   *    - basePages: array, uncondtionally load this module onto the given Angular pages. [v4.7.21+]
+   *      If omitted, default to "array('civicrm/a')" for backward compat.
+   *      For a utility that should only be loaded on-demand, use "array()".
+   *      For a utility that should be loaded in all pages use, "array('*')".
    * @return null
    *   the return value is ignored
    *
@@ -2096,6 +2114,7 @@ abstract class CRM_Utils_Hook {
    *     'css' => array('css/myAngularModule.css'),
    *     'partials' => array('partials/myBigAngularModule'),
    *     'requires' => array('otherModuleA', 'otherModuleB'),
+   *     'basePages' => array('civicrm/a'),
    *   );
    * }
    * @endcode
@@ -2107,6 +2126,28 @@ abstract class CRM_Utils_Hook {
     );
   }
 
+  /**
+   * Alter the definition of some Angular HTML partials.
+   *
+   * @param \Civi\Angular\Manager $angular
+   *
+   * @code
+   * function example_civicrm_alterAngular($angular) {
+   *   $angular->add(ChangeSet::create('mychanges')
+   *     ->alterHtml('~/crmMailing/EditMailingCtrl/2step.html', function(phpQueryObject $doc) {
+   *       $doc->find('[ng-form="crmMailingSubform"]')->attr('cat-stevens', 'ts(\'wild world\')');
+   *     })
+   *   );
+   * }
+   * @endCode
+   */
+  public static function alterAngular($angular) {
+    $event = \Civi\Core\Event\GenericHookEvent::create(array(
+      'angular' => $angular,
+    ));
+    Civi::dispatcher()->dispatch('hook_civicrm_alterAngular', $event);
+  }
+
   /**
    * This hook is called whenever the system builds a new copy of
    * semi-static asset.