* but also accepts enough information to support Symfony Event
* dispatching.
*
- * @param array|int $names
+ * @param array $names
* (Recommended) Array of parameter names, in order.
* Using an array is recommended because it enables full
* event-broadcasting behaviors.
&$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6,
$fnSuffix
) {
- if (!\Civi\Core\Container::isContainerBooted()) {
- $prebootHooks = ['civicrm_container', 'civicrm_entityTypes'];
- // 'civicrm_config' ?
- if (in_array($fnSuffix, $prebootHooks)) {
- $count = is_array($names) ? count($names) : $names;
- return $this->invokeViaUF($count, $arg1, $arg2, $arg3, $arg4, $arg5, $arg6, $fnSuffix);
- }
- else {
- // TODO: Emit a warning, eg
- // error_log("Warning: hook_$fnSuffix fired prematurely. Dropped.");
- return;
- }
- }
-
if (!is_array($names)) {
// We were called with the old contract wherein $names is actually an int.
// Symfony dispatcher requires some kind of name.
- // TODO: Emit a warning, eg
- // error_log("Warning: hook_$fnSuffix does not give names for its parameters. It will present odd names to any Symfony event listeners.");
+ Civi::log()->warning("hook_$fnSuffix should be updated to pass an array of parameter names to CRM_Utils_Hook::invoke().", ['civi.tag' => 'deprecated']);
$compatNames = ['arg1', 'arg2', 'arg3', 'arg4', 'arg5', 'arg6'];
$names = array_slice($compatNames, 0, (int) $names);
}
$event = \Civi\Core\Event\GenericHookEvent::createOrdered(
$names,
- array(&$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6)
+ [&$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6]
);
\Civi::dispatcher()->dispatch('hook_' . $fnSuffix, $event);
return $event->getReturnValues();
->invoke(['op', 'groupID', 'entityID', 'params'], $op, $groupID, $entityID, $params, self::$_nullObject, self::$_nullObject, 'civicrm_custom');
}
+ /**
+ * This hook is called before a db write on a custom table.
+ *
+ * @param string $op
+ * The type of operation being performed.
+ * @param string $groupID
+ * The custom group ID.
+ * @param object $entityID
+ * The entityID of the row in the custom table.
+ * @param array $params
+ * The parameters that were sent into the calling function.
+ *
+ * @return null
+ * the return value is ignored
+ */
+ public static function customPre($op, $groupID, $entityID, &$params) {
+ return self::singleton()
+ ->invoke(['op', 'groupID', 'entityID', 'params'], $op, $groupID, $entityID, $params, self::$_nullObject, self::$_nullObject, 'civicrm_customPre');
+ }
+
/**
* This hook is called when composing the ACL where clause to restrict
* visibility of contacts to the logged in user
* the return value is ignored
*/
public static function activeTheme(&$theme, $context) {
- return self::singleton()->invoke(array('theme', 'context'), $theme, $context,
+ return self::singleton()->invoke(['theme', 'context'], $theme, $context,
self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
'civicrm_activeTheme'
);
* @return mixed
*/
public static function alterAdminPanel(&$panels) {
- return self::singleton()->invoke(array('panels'), $panels,
+ return self::singleton()->invoke(['panels'], $panels,
self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
'civicrm_alterAdminPanel'
);
/**
* Check system status.
*
- * @param array $messages
- * Array<CRM_Utils_Check_Message>. A list of messages regarding system status.
+ * @param CRM_Utils_Check_Message[] $messages
+ * A list of messages regarding system status
+ * @param array $statusNames
+ * If specified, only these checks are being requested and others should be skipped
+ * @param bool $includeDisabled
+ * Run checks that have been explicitly disabled (default false)
* @return mixed
*/
- public static function check(&$messages) {
- return self::singleton()
- ->invoke(['messages'], $messages, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, 'civicrm_check');
+ public static function check(&$messages, $statusNames = [], $includeDisabled = FALSE) {
+ return self::singleton()->invoke(['messages'],
+ $messages, $statusNames, $includeDisabled,
+ self::$_nullObject, self::$_nullObject, self::$_nullObject,
+ 'civicrm_check'
+ );
}
/**