/**
* @param array $filters
* Filter by property (e.g. 'id').
+ *
* @return array
* Array(scalar $id => Mapping $mapping).
+ * @throws \CRM_Core_Exception
*/
public static function getMappings($filters = NULL) {
static $_action_mapping;
if ($_action_mapping === NULL) {
- $event = \Civi\Core\Container::singleton()->get('dispatcher')
+ $event = \Civi::dispatcher()
->dispatch(\Civi\ActionSchedule\Events::MAPPINGS,
new \Civi\ActionSchedule\Event\MappingRegisterEvent());
$_action_mapping = $event->getMappings();
$select->where("e.id = reminder.entity_id OR reminder.entity_table = 'civicrm_contact'");
}
- \Civi\Core\Container::singleton()->get('dispatcher')
+ \Civi::dispatcher()
->dispatch(
\Civi\ActionSchedule\Events::MAILING_QUERY,
new \Civi\ActionSchedule\Event\MailingQueryEvent($actionSchedule, $mapping, $select)
* @return \Civi\Token\TokenProcessor
*/
protected static function createTokenProcessor($schedule, $mapping) {
- $tp = new \Civi\Token\TokenProcessor(\Civi\Core\Container::singleton()->get('dispatcher'), [
+ $tp = new \Civi\Token\TokenProcessor(\Civi::dispatcher(), [
'controller' => __CLASS__,
'actionSchedule' => $schedule,
'actionMapping' => $mapping,
}
// OK, this looks new.
- Civi::service('dispatcher')->dispatch(\Civi\Core\Event\SystemInstallEvent::EVENT_NAME, new \Civi\Core\Event\SystemInstallEvent());
+ Civi::dispatcher()->dispatch(\Civi\Core\Event\SystemInstallEvent::EVENT_NAME, new \Civi\Core\Event\SystemInstallEvent());
Civi::settings()->set('installed', 1);
}
if (!empty($this->id)) {
if ($hook) {
$preEvent = new \Civi\Core\DAO\Event\PreUpdate($this);
- \Civi::service('dispatcher')->dispatch("civi.dao.preUpdate", $preEvent);
+ \Civi::dispatcher()->dispatch("civi.dao.preUpdate", $preEvent);
}
$result = $this->update();
if ($hook) {
$event = new \Civi\Core\DAO\Event\PostUpdate($this, $result);
- \Civi::service('dispatcher')->dispatch("civi.dao.postUpdate", $event);
+ \Civi::dispatcher()->dispatch("civi.dao.postUpdate", $event);
}
$this->clearDbColumnValueCache();
}
else {
if ($hook) {
$preEvent = new \Civi\Core\DAO\Event\PreUpdate($this);
- \Civi::service('dispatcher')->dispatch("civi.dao.preInsert", $preEvent);
+ \Civi::dispatcher()->dispatch("civi.dao.preInsert", $preEvent);
}
$result = $this->insert();
if ($hook) {
$event = new \Civi\Core\DAO\Event\PostUpdate($this, $result);
- \Civi::service('dispatcher')->dispatch("civi.dao.postInsert", $event);
+ \Civi::dispatcher()->dispatch("civi.dao.postInsert", $event);
}
}
$this->free();
*/
public function delete($useWhere = FALSE) {
$preEvent = new \Civi\Core\DAO\Event\PreDelete($this);
- \Civi::service('dispatcher')->dispatch("civi.dao.preDelete", $preEvent);
+ \Civi::dispatcher()->dispatch("civi.dao.preDelete", $preEvent);
$result = parent::delete($useWhere);
$event = new \Civi\Core\DAO\Event\PostDelete($this, $result);
- \Civi::service('dispatcher')->dispatch("civi.dao.postDelete", $event);
+ \Civi::dispatcher()->dispatch("civi.dao.postDelete", $event);
$this->free();
$this->clearDbColumnValueCache();
}
$whitelist = \Civi\API\WhitelistRule::createAll($cxn['perm']['api']);
- \Civi::service('dispatcher')
+ \Civi::dispatcher()
->addSubscriber(new \Civi\API\Subscriber\WhitelistSubscriber($whitelist));
CRM_Core_Config::singleton()->userPermissionTemp = new CRM_Core_Permission_Temp();
if ($cxn['perm']['grant'] === '*') {
'absolute' => $absolute,
'isSSL' => $isSSL,
]);
- Civi::service('dispatcher')->dispatch('hook_civicrm_alterExternUrl', $event);
+ Civi::dispatcher()->dispatch('hook_civicrm_alterExternUrl', $event);
return urldecode(CRM_Utils_Url::unparseUrl($event->url));
}
* $event->bang->objProperty = 'abcd';
*
* // Dispatching an event.
- * Civi::service('dispatcher')->dispatch('hook_civicrm_foo', $event);
+ * Civi::dispatcher()->dispatch('hook_civicrm_foo', $event);
* @endCode
*
* Design Discussion:
* @param \Civi\Core\Event\PostEvent $event
*/
public static function dispatchSubevent(PostEvent $event) {
- \Civi::service('dispatcher')->dispatch("hook_civicrm_post::" . $event->entity, $event);
+ \Civi::dispatcher()->dispatch("hook_civicrm_post::" . $event->entity, $event);
}
/**
* @param \Civi\Core\Event\PreEvent $event
*/
public static function dispatchSubevent(PreEvent $event) {
- \Civi::service('dispatcher')->dispatch("hook_civicrm_pre::" . $event->entity, $event);
+ \Civi::dispatcher()->dispatch("hook_civicrm_pre::" . $event->entity, $event);
}
/**
]);
$contact = CRM_Core_DAO::createTestObject('CRM_Contact_DAO_Contact');
- $p = new \Civi\Token\TokenProcessor(Civi::service('dispatcher'), [
+ $p = new \Civi\Token\TokenProcessor(Civi::dispatcher(), [
'mailingId' => $mailing->id,
]);
$p->addMessage('example', $inputTemplate, $inputTemplateFormat);
]);
$contact = CRM_Core_DAO::createTestObject('CRM_Contact_DAO_Contact');
- $p = new \Civi\Token\TokenProcessor(Civi::service('dispatcher'), [
+ $p = new \Civi\Token\TokenProcessor(Civi::dispatcher(), [
'mailing' => $mailing,
]);
$p->addMessage('example', $inputTemplate, $inputTemplateFormat);
]);
$contact = CRM_Core_DAO::createTestObject('CRM_Contact_DAO_Contact');
- $p = new \Civi\Token\TokenProcessor(Civi::service('dispatcher'), [
+ $p = new \Civi\Token\TokenProcessor(Civi::dispatcher(), [
'mailing' => $mailing,
]);
$p->addMessage('example', $inputTemplateText, $inputTemplateFormat);
* @dataProvider getExternURLs
*/
public function testAlterExternUrlHook($path, $expected) {
- Civi::service('dispatcher')->addListener('hook_civicrm_alterExternUrl', [$this, 'hook_civicrm_alterExternUrl']);
+ Civi::dispatcher()->addListener('hook_civicrm_alterExternUrl', [$this, 'hook_civicrm_alterExternUrl']);
$externUrl = CRM_Utils_System::externUrl($path, $expected['query']);
$this->assertContains('path/altered/by/hook', $externUrl, 'Hook failed to alter URL path');
$this->assertContains($expected['query'] . '&thisWas=alteredByHook', $externUrl, 'Hook failed to alter URL query');
public function testDispatch() {
\CRM_Utils_Hook::singleton()->setHook('civicrm_ghet',
[$this, 'hook_civicrm_ghet']);
- \Civi::service('dispatcher')->addListener('hook_civicrm_ghet',
+ \Civi::dispatcher()->addListener('hook_civicrm_ghet',
[$this, 'onGhet']);
$roString = 'readonly';