/**
* Access Control List
*/
-class CRM_ACL_BAO_ACL extends CRM_ACL_DAO_ACL implements \Civi\Test\HookInterface {
+class CRM_ACL_BAO_ACL extends CRM_ACL_DAO_ACL implements \Civi\Core\HookInterface {
/**
* Available operations for pseudoconstant.
/**
* Class CRM_Campaign_BAO_Survey.
*/
-class CRM_Campaign_BAO_Survey extends CRM_Campaign_DAO_Survey implements Civi\Test\HookInterface {
+class CRM_Campaign_BAO_Survey extends CRM_Campaign_DAO_Survey implements Civi\Core\HookInterface {
/**
* Retrieve DB object and copy to defaults array.
/**
* This class contains the functions for Case Type management.
*/
-class CRM_Case_BAO_CaseType extends CRM_Case_DAO_CaseType implements \Civi\Test\HookInterface {
+class CRM_Case_BAO_CaseType extends CRM_Case_DAO_CaseType implements \Civi\Core\HookInterface {
/**
* Static field for all the case information that we can potentially export.
* @package CRM
* @copyright CiviCRM LLC https://civicrm.org/licensing
*/
-class CRM_Contact_BAO_Contact extends CRM_Contact_DAO_Contact implements Civi\Test\HookInterface {
+class CRM_Contact_BAO_Contact extends CRM_Contact_DAO_Contact implements Civi\Core\HookInterface {
/**
* SQL function used to format the phone_numeric field via trigger.
* @package CRM
* @copyright CiviCRM LLC https://civicrm.org/licensing
*/
-class CRM_Contact_BAO_ContactType extends CRM_Contact_DAO_ContactType implements \Civi\Test\HookInterface {
+class CRM_Contact_BAO_ContactType extends CRM_Contact_DAO_ContactType implements \Civi\Core\HookInterface {
/**
* Retrieve DB object and copy to defaults array.
/**
* Class CRM_Contact_BAO_RelationshipCache.
*/
-class CRM_Contact_BAO_RelationshipCache extends CRM_Contact_DAO_RelationshipCache implements \Civi\Test\HookInterface {
+class CRM_Contact_BAO_RelationshipCache extends CRM_Contact_DAO_RelationshipCache implements \Civi\Core\HookInterface {
/**
* The "mappings" array defines the values to put into `civicrm_relationship_cache`
* @package CRM
* @copyright CiviCRM LLC https://civicrm.org/licensing
*/
-class CRM_Contact_BAO_RelationshipType extends CRM_Contact_DAO_RelationshipType implements \Civi\Test\HookInterface {
+class CRM_Contact_BAO_RelationshipType extends CRM_Contact_DAO_RelationshipType implements \Civi\Core\HookInterface {
/**
* Retrieve DB object and copy to defaults array.
/**
* This class contains functions for email handling.
*/
-class CRM_Core_BAO_Email extends CRM_Core_DAO_Email implements Civi\Test\HookInterface {
+class CRM_Core_BAO_Email extends CRM_Core_DAO_Email implements Civi\Core\HookInterface {
use CRM_Contact_AccessTrait;
/**
* @package CRM
* @copyright CiviCRM LLC https://civicrm.org/licensing
*/
-class CRM_Core_BAO_LocationType extends CRM_Core_DAO_LocationType implements \Civi\Test\HookInterface {
+class CRM_Core_BAO_LocationType extends CRM_Core_DAO_LocationType implements \Civi\Core\HookInterface {
/**
* @var CRM_Core_DAO_LocationType|null
/**
* This class contains functions for managed entities.
*/
-class CRM_Core_BAO_Managed extends CRM_Core_DAO_Managed implements Civi\Test\HookInterface {
+class CRM_Core_BAO_Managed extends CRM_Core_DAO_Managed implements Civi\Core\HookInterface {
/**
* Callback for hook_civicrm_post().
* @package CRM
* @copyright CiviCRM LLC https://civicrm.org/licensing
*/
-class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping implements \Civi\Test\HookInterface {
+class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping implements \Civi\Core\HookInterface {
/**
* Retrieve DB object and copy to defaults array.
/**
* Class CRM_Core_BAO_MessageTemplate.
*/
-class CRM_Core_BAO_MessageTemplate extends CRM_Core_DAO_MessageTemplate implements \Civi\Test\HookInterface {
+class CRM_Core_BAO_MessageTemplate extends CRM_Core_DAO_MessageTemplate implements \Civi\Core\HookInterface {
/**
* Retrieve DB object and copy to defaults array.
/**
* BAO object for crm_note table.
*/
-class CRM_Core_BAO_Note extends CRM_Core_DAO_Note implements \Civi\Test\HookInterface {
+class CRM_Core_BAO_Note extends CRM_Core_DAO_Note implements \Civi\Core\HookInterface {
use CRM_Core_DynamicFKAccessTrait;
/**
* @package CRM
* @copyright CiviCRM LLC https://civicrm.org/licensing
*/
-class CRM_Core_BAO_OptionGroup extends CRM_Core_DAO_OptionGroup implements \Civi\Test\HookInterface {
+class CRM_Core_BAO_OptionGroup extends CRM_Core_DAO_OptionGroup implements \Civi\Core\HookInterface {
/**
* Retrieve DB object and copy to defaults array.
* @package CRM
* @copyright CiviCRM LLC https://civicrm.org/licensing
*/
-class CRM_Core_BAO_Translation extends CRM_Core_DAO_Translation implements \Civi\Test\HookInterface {
+class CRM_Core_BAO_Translation extends CRM_Core_DAO_Translation implements \Civi\Core\HookInterface {
use CRM_Core_DynamicFKAccessTrait;
/**
* Class CRM_Core_BAO_WordReplacement.
*/
-class CRM_Core_BAO_WordReplacement extends CRM_Core_DAO_WordReplacement implements \Civi\Test\HookInterface {
+class CRM_Core_BAO_WordReplacement extends CRM_Core_DAO_WordReplacement implements \Civi\Core\HookInterface {
/**
* Retrieve DB object and copy to defaults array.
* @package CRM
* @copyright CiviCRM LLC https://civicrm.org/licensing
*/
-class CRM_Financial_BAO_FinancialAccount extends CRM_Financial_DAO_FinancialAccount implements \Civi\Test\HookInterface {
+class CRM_Financial_BAO_FinancialAccount extends CRM_Financial_DAO_FinancialAccount implements \Civi\Core\HookInterface {
/**
* Retrieve DB object and copy to defaults array.
* @package CRM
* @copyright CiviCRM LLC https://civicrm.org/licensing
*/
-class CRM_Financial_BAO_FinancialType extends CRM_Financial_DAO_FinancialType implements \Civi\Test\HookInterface {
+class CRM_Financial_BAO_FinancialType extends CRM_Financial_DAO_FinancialType implements \Civi\Core\HookInterface {
/**
* Static cache holder of available financial types for this session
/**
* This class contains payment processor related functions.
*/
-class CRM_Financial_BAO_PaymentProcessor extends CRM_Financial_DAO_PaymentProcessor implements \Civi\Test\HookInterface {
+class CRM_Financial_BAO_PaymentProcessor extends CRM_Financial_DAO_PaymentProcessor implements \Civi\Core\HookInterface {
/**
* Static holder for the default payment processor
* @var object
* @package CRM
* @copyright CiviCRM LLC https://civicrm.org/licensing
*/
-class CRM_Financial_BAO_PaymentProcessorType extends CRM_Financial_DAO_PaymentProcessorType implements \Civi\Test\HookInterface {
+class CRM_Financial_BAO_PaymentProcessorType extends CRM_Financial_DAO_PaymentProcessorType implements \Civi\Core\HookInterface {
/**
* Static holder for the default payment processor.
* @package CRM
* @copyright CiviCRM LLC https://civicrm.org/licensing
*/
-class CRM_Member_BAO_MembershipStatus extends CRM_Member_DAO_MembershipStatus implements \Civi\Test\HookInterface {
+class CRM_Member_BAO_MembershipStatus extends CRM_Member_DAO_MembershipStatus implements \Civi\Core\HookInterface {
/**
* Retrieve DB object and copy to defaults array.
* @package CRM
* @copyright CiviCRM LLC https://civicrm.org/licensing
*/
-class CRM_Member_BAO_MembershipType extends CRM_Member_DAO_MembershipType implements \Civi\Test\HookInterface {
+class CRM_Member_BAO_MembershipType extends CRM_Member_DAO_MembershipType implements \Civi\Core\HookInterface {
/**
* Static holder for the default Membership Type.
* @package CRM
* @copyright CiviCRM LLC https://civicrm.org/licensing
*/
-class CRM_Report_BAO_ReportInstance extends CRM_Report_DAO_ReportInstance implements Civi\Test\HookInterface {
+class CRM_Report_BAO_ReportInstance extends CRM_Report_DAO_ReportInstance implements Civi\Core\HookInterface {
/**
* Takes an associative array and creates an instance object.
}
$listenerMap = [];
- // FIXME: Inteface misnomer
- if (is_subclass_of($class, '\Civi\Test\HookInterface')) {
+ // These 2 interfaces do the same thing; one is meant for unit tests and the other for runtime code
+ if (is_subclass_of($class, '\Civi\Test\HookInterface') || is_subclass_of($class, '\Civi\Core\HookInterface')) {
$listenerMap = static::mergeListenerMap($listenerMap, static::findFunctionListeners($class, $self));
}
if (is_subclass_of($class, '\Symfony\Component\EventDispatcher\EventSubscriberInterface')) {
--- /dev/null
+<?php
+
+namespace Civi\Core;
+
+/**
+ * Interface HookInterface
+ * @package Civi\Core
+ *
+ * This interface allows CRM_BAO classes to subscribe to hooks.
+ * Simply create an eponymous hook function (e.g. `hook_civicrm_post()`).
+ *
+ * ```
+ * class CRM_Foo_BAO_Bar implements \Civi\Core\HookInterface {
+ * public function hook_civicrm_post($op, $objectName, $objectId, &$objectRef) {
+ * echo "Running hook_civicrm_post\n";
+ * }
+ * }
+ * ```
+ *
+ * Similarly, to subscribe using Symfony-style listeners, create function with the 'on_' prefix:
+ *
+ * ```
+ * class CRM_Foo_BAO_Bar implements \Civi\Core\HookInterface {
+ * public function on_civi_api_authorize(AuthorizeEvent $e): void {
+ * echo "Running civi.api.authorize\n";
+ * }
+ * public function on_hook_civicrm_post(GenericHookEvent $e): void {
+ * echo "Running hook_civicrm_post\n";
+ * }
+ * }
+ * ```
+ *
+ * If you need more advanced registration abilities, consider using `Civi::dispatcher()`
+ * or `EventDispatcherInterface`.
+ *
+ * @see \Civi\Core\Event\EventScanner::findListeners
+ */
+interface HookInterface {
+}