Commit 048222df authored by totten's avatar totten
Browse files

\Civi - Use facade instead of Civi\Core\Container::singleton()

parent 711aa5d7
......@@ -119,7 +119,7 @@ class CRM_Admin_Form_Job extends CRM_Admin_Form {
require_once 'api/api.php';
/** @var \Civi\API\Kernel $apiKernel */
$apiKernel = \Civi\Core\Container::singleton()->get('civi_api_kernel');
$apiKernel = \Civi::service('civi_api_kernel');
$apiRequest = \Civi\API\Request::create($fields['api_entity'], $fields['api_action'], array('version' => 3), NULL);
try {
$apiKernel->resolve($apiRequest);
......
......@@ -431,7 +431,7 @@ WHERE id = %1
}
// grab a lock so other processes dont compete and do the same query
$lock = Civi\Core\Container::singleton()->get('lockManager')->acquire("data.core.group.{$groupID}");
$lock = Civi::service('lockManager')->acquire("data.core.group.{$groupID}");
if (!$lock->isAcquired()) {
// this can cause inconsistent results since we dont know if the other process
// will fill up the cache before our calling routine needs it.
......
......@@ -153,7 +153,7 @@ class CRM_Core_BAO_Cache extends CRM_Core_DAO_Cache {
// get a lock so that multiple ajax requests on the same page
// dont trample on each other
// CRM-11234
$lock = Civi\Core\Container::singleton()->get('lockManager')->acquire("cache.{$group}_{$path}._{$componentID}");
$lock = Civi::service('lockManager')->acquire("cache.{$group}_{$path}._{$componentID}");
if (!$lock->isAcquired()) {
CRM_Core_Error::fatal();
}
......
......@@ -525,7 +525,7 @@ class CRM_Core_Config extends CRM_Core_Config_Variables {
* @deprecated
*/
public static function getMailer() {
return Civi\Core\Container::singleton()->get('pear_mail');
return Civi::service('pear_mail');
}
/**
......
......@@ -434,13 +434,13 @@ class CRM_Core_DAO extends DB_DataObject {
$this->update();
$event = new \Civi\Core\DAO\Event\PostUpdate($this);
\Civi\Core\Container::singleton()->get('dispatcher')->dispatch("DAO::post-update", $event);
\Civi::service('dispatcher')->dispatch("DAO::post-update", $event);
}
else {
$this->insert();
$event = new \Civi\Core\DAO\Event\PostUpdate($this);
\Civi\Core\Container::singleton()->get('dispatcher')->dispatch("DAO::post-insert", $event);
\Civi::service('dispatcher')->dispatch("DAO::post-insert", $event);
}
$this->free();
......@@ -478,7 +478,7 @@ class CRM_Core_DAO extends DB_DataObject {
$result = parent::delete($useWhere);
$event = new \Civi\Core\DAO\Event\PostDelete($this, $result);
\Civi\Core\Container::singleton()->get('dispatcher')->dispatch("DAO::post-delete", $event);
\Civi::service('dispatcher')->dispatch("DAO::post-delete", $event);
return $result;
}
......
......@@ -75,8 +75,7 @@ class CRM_Cxn_ApiRouter {
}
$whitelist = \Civi\API\WhitelistRule::createAll($cxn['perm']['api']);
Civi\Core\Container::singleton()
->get('dispatcher')
\Civi::service('dispatcher')
->addSubscriber(new \Civi\API\Subscriber\WhitelistSubscriber($whitelist));
CRM_Core_Config::singleton()->userPermissionTemp = new CRM_Core_Permission_Temp();
if ($cxn['perm']['grant'] === '*') {
......
......@@ -2853,7 +2853,7 @@ WHERE civicrm_mailing_job.id = %1
// check if we are using global locks
foreach ($lockArray as $lockID) {
$cronLock = Civi\Core\Container::singleton()->get('lockManager')->acquire("worker.mailing.send.{$lockID}");
$cronLock = Civi::service('lockManager')->acquire("worker.mailing.send.{$lockID}");
if ($cronLock->isAcquired()) {
$gotCronLock = TRUE;
break;
......
......@@ -136,7 +136,7 @@ class CRM_Mailing_BAO_MailingJob extends CRM_Mailing_DAO_MailingJob {
while ($job->fetch()) {
// still use job level lock for each child job
$lock = Civi\Core\Container::singleton()->get('lockManager')->acquire("data.mailing.job.{$job->id}");
$lock = Civi::service('lockManager')->acquire("data.mailing.job.{$job->id}");
if (!$lock->isAcquired()) {
continue;
}
......@@ -185,7 +185,7 @@ class CRM_Mailing_BAO_MailingJob extends CRM_Mailing_DAO_MailingJob {
// Get the mailer
if ($mode === NULL) {
$mailer = \Civi\Core\Container::singleton()->get('pear_mail');
$mailer = \Civi::service('pear_mail');
}
elseif ($mode == 'sms') {
$mailer = CRM_SMS_Provider::singleton(array('mailing_id' => $job->mailing_id));
......@@ -341,7 +341,7 @@ class CRM_Mailing_BAO_MailingJob extends CRM_Mailing_DAO_MailingJob {
// X Number of child jobs
while ($job->fetch()) {
// still use job level lock for each child job
$lock = Civi\Core\Container::singleton()->get('lockManager')->acquire("data.mailing.job.{$job->id}");
$lock = Civi::service('lockManager')->acquire("data.mailing.job.{$job->id}");
if (!$lock->isAcquired()) {
continue;
}
......
......@@ -172,7 +172,7 @@ class CRM_Mailing_Event_BAO_Forward extends CRM_Mailing_Event_DAO_Forward {
$mailing_obj->find(TRUE);
$config = CRM_Core_Config::singleton();
$mailer = \Civi\Core\Container::singleton()->get('pear_mail');
$mailer = \Civi::service('pear_mail');
$recipient = NULL;
$attachments = NULL;
......
......@@ -201,7 +201,7 @@ class CRM_Mailing_Event_BAO_Reply extends CRM_Mailing_Event_DAO_Reply {
CRM_Mailing_BAO_Mailing::addMessageIdHeader($h, 'r', $eq->job_id, $queue_id, $eq->hash);
$config = CRM_Core_Config::singleton();
$mailer = \Civi\Core\Container::singleton()->get('pear_mail');
$mailer = \Civi::service('pear_mail');
if (is_object($mailer)) {
$errorScope = CRM_Core_TemporaryErrorScope::ignoreException();
......@@ -293,7 +293,7 @@ class CRM_Mailing_Event_BAO_Reply extends CRM_Mailing_Event_DAO_Reply {
$h = $message->headers($headers);
CRM_Mailing_BAO_Mailing::addMessageIdHeader($h, 'a', $eq->job_id, queue_id, $eq->hash);
$mailer = \Civi\Core\Container::singleton()->get('pear_mail');
$mailer = \Civi::service('pear_mail');
if (is_object($mailer)) {
$errorScope = CRM_Core_TemporaryErrorScope::ignoreException();
$mailer->send($to, $h, $b);
......
......@@ -287,7 +287,7 @@ class CRM_Mailing_Event_BAO_Resubscribe {
$b = CRM_Utils_Mail::setMimeParams($message);
$h = $message->headers($headers);
$mailer = \Civi\Core\Container::singleton()->get('pear_mail');
$mailer = \Civi::service('pear_mail');
if (is_object($mailer)) {
$errorScope = CRM_Core_TemporaryErrorScope::ignoreException();
......
......@@ -291,7 +291,7 @@ SELECT civicrm_email.id as email_id
$this->id,
$this->hash
);
$mailer = \Civi\Core\Container::singleton()->get('pear_mail');
$mailer = \Civi::service('pear_mail');
if (is_object($mailer)) {
$errorScope = CRM_Core_TemporaryErrorScope::ignoreException();
......
......@@ -406,7 +406,7 @@ WHERE email = %2
$b = CRM_Utils_Mail::setMimeParams($message);
$h = $message->headers($headers);
$mailer = \Civi\Core\Container::singleton()->get('pear_mail');
$mailer = \Civi::service('pear_mail');
if (is_object($mailer)) {
$errorScope = CRM_Core_TemporaryErrorScope::ignoreException();
......
......@@ -273,8 +273,8 @@ abstract class CRM_Utils_Hook {
*/
public static function pre($op, $objectName, $id, &$params) {
$event = new \Civi\Core\Event\PreEvent($op, $objectName, $id, $params);
\Civi\Core\Container::singleton()->get('dispatcher')->dispatch("hook_civicrm_pre", $event);
\Civi\Core\Container::singleton()->get('dispatcher')->dispatch("hook_civicrm_pre::$objectName", $event);
\Civi::service('dispatcher')->dispatch("hook_civicrm_pre", $event);
\Civi::service('dispatcher')->dispatch("hook_civicrm_pre::$objectName", $event);
return self::singleton()
->invoke(4, $op, $objectName, $id, $params, self::$_nullObject, self::$_nullObject, 'civicrm_pre');
}
......@@ -297,8 +297,8 @@ abstract class CRM_Utils_Hook {
*/
public static function post($op, $objectName, $objectId, &$objectRef) {
$event = new \Civi\Core\Event\PostEvent($op, $objectName, $objectId, $objectRef);
\Civi\Core\Container::singleton()->get('dispatcher')->dispatch("hook_civicrm_post", $event);
\Civi\Core\Container::singleton()->get('dispatcher')->dispatch("hook_civicrm_post::$objectName", $event);
\Civi::service('dispatcher')->dispatch("hook_civicrm_post", $event);
\Civi::service('dispatcher')->dispatch("hook_civicrm_post::$objectName", $event);
return self::singleton()
->invoke(4, $op, $objectName, $objectId, $objectRef, self::$_nullObject, self::$_nullObject, 'civicrm_post');
}
......@@ -1611,7 +1611,7 @@ abstract class CRM_Utils_Hook {
// == 4.5+ ==
$event = new \Civi\Core\Event\UnhandledExceptionEvent($exception, self::$_nullObject);
\Civi\Core\Container::singleton()->get('dispatcher')->dispatch("hook_civicrm_unhandled_exception", $event);
\Civi::service('dispatcher')->dispatch("hook_civicrm_unhandled_exception", $event);
}
/**
......@@ -1861,7 +1861,7 @@ abstract class CRM_Utils_Hook {
*/
public static function caseChange(\Civi\CCase\Analyzer $analyzer) {
$event = new \Civi\CCase\Event\CaseChangeEvent($analyzer);
\Civi\Core\Container::singleton()->get('dispatcher')->dispatch("hook_civicrm_caseChange", $event);
\Civi::service('dispatcher')->dispatch("hook_civicrm_caseChange", $event);
return self::singleton()->invoke(1, $angularModules,
self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
......
......@@ -260,7 +260,7 @@ class CRM_Utils_Mail {
$to = array($params['toEmail']);
$result = NULL;
$mailer = \Civi\Core\Container::singleton()->get('pear_mail');
$mailer = \Civi::service('pear_mail');
// Mail_smtp and Mail_sendmail mailers require Bcc anc Cc emails
// be included in both $to and $headers['Cc', 'Bcc']
......
......@@ -50,7 +50,7 @@ class Main extends \CRM_Core_Page {
public function __construct($title = NULL, $mode = NULL, $res = NULL) {
parent::__construct($title, $mode);
$this->res = \CRM_Core_Resources::singleton();
$this->angular = \Civi\Core\Container::singleton()->get('angular');
$this->angular = \Civi::service('angular');
$this->region = \CRM_Utils_Request::retrieve('snippet', 'String') ? 'ajax-snippet' : 'html-header';
}
......
......@@ -26,7 +26,7 @@ class Modules extends \CRM_Core_Page {
/**
* @var \Civi\Angular\Manager $angular
*/
$angular = \Civi\Core\Container::singleton()->get('angular');
$angular = \Civi::service('angular');
$moduleNames = $this->parseModuleNames(\CRM_Utils_Request::retrieve('modules', 'String'), $angular);
switch (\CRM_Utils_Request::retrieve('format', 'String')) {
......
......@@ -72,11 +72,11 @@ class Resolver {
switch ($url['scheme']) {
case 'obj':
// Object: Lookup in container.
return Container::singleton()->get($url['host']);
return \Civi::service($url['host']);
case 'call':
// Callback: Object/method in container.
$obj = Container::singleton()->get($url['host']);
$obj = \Civi::service($url['host']);
return array($obj, ltrim($url['path'], '/'));
case 'api3':
......
......@@ -20,7 +20,7 @@
* @return array|int
*/
function civicrm_api($entity, $action, $params, $extra = NULL) {
return \Civi\Core\Container::singleton()->get('civi_api_kernel')->run($entity, $action, $params, $extra);
return \Civi::service('civi_api_kernel')->run($entity, $action, $params, $extra);
}
/**
......
......@@ -91,7 +91,7 @@ function civicrm_api3_cxn_register($params) {
try {
/** @var \Civi\Cxn\Rpc\RegistrationClient $client */
$client = \Civi\Core\Container::singleton()->get('cxn_reg_client');
$client = \Civi::service('cxn_reg_client');
list($cxnId, $result) = $client->register($appMeta);
CRM_Cxn_BAO_Cxn::updateAppMeta($appMeta);
}
......@@ -133,7 +133,7 @@ function civicrm_api3_cxn_unregister($params) {
$appMeta = CRM_Cxn_BAO_Cxn::getAppMeta($cxnId);
/** @var \Civi\Cxn\Rpc\RegistrationClient $client */
$client = \Civi\Core\Container::singleton()->get('cxn_reg_client');
$client = \Civi::service('cxn_reg_client');
list($cxnId, $result) = $client->unregister($appMeta, CRM_Utils_Array::value('force', $params, FALSE));
return $result;
......@@ -240,7 +240,7 @@ function civicrm_api3_cxn_getlink($params) {
}
/** @var \Civi\Cxn\Rpc\RegistrationClient $client */
$client = \Civi\Core\Container::singleton()->get('cxn_reg_client');
$client = \Civi::service('cxn_reg_client');
return $client->call($appMeta, 'Cxn', 'getlink', array(
'page' => $params['page'],
));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment