当前位置: 首页>>代码示例>>PHP>>正文


PHP Civi::service方法代码示例

本文整理汇总了PHP中Civi::service方法的典型用法代码示例。如果您正苦于以下问题:PHP Civi::service方法的具体用法?PHP Civi::service怎么用?PHP Civi::service使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Civi的用法示例。


在下文中一共展示了Civi::service方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: route

 /**
  * @param array $cxn
  * @param string $entity
  * @param string $action
  * @param array $params
  * @return mixed
  */
 public static function route($cxn, $entity, $action, $params)
 {
     $SUPER_PERM = array('administer CiviCRM');
     require_once 'api/v3/utils.php';
     // FIXME: Shouldn't the X-Forwarded-Proto check be part of CRM_Utils_System::isSSL()?
     if (CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'enableSSL') && !CRM_Utils_System::isSSL() && strtolower(CRM_Utils_Array::value('X_FORWARDED_PROTO', CRM_Utils_System::getRequestHeaders())) != 'https') {
         return civicrm_api3_create_error('System policy requires HTTPS.');
     }
     // Note: $cxn and cxnId are authenticated before router is called.
     $dao = new CRM_Cxn_DAO_Cxn();
     $dao->cxn_id = $cxn['cxnId'];
     if (empty($cxn['cxnId']) || !$dao->find(TRUE) || !$dao->cxn_id) {
         return civicrm_api3_create_error('Failed to lookup connection authorizations.');
     }
     if (!$dao->is_active) {
         return civicrm_api3_create_error('Connection is inactive.');
     }
     if (!is_string($entity) || !is_string($action) || !is_array($params)) {
         return civicrm_api3_create_error('API parameters are malformed.');
     }
     if (empty($cxn['perm']['api']) || !is_array($cxn['perm']['api']) || empty($cxn['perm']['grant']) || !(is_array($cxn['perm']['grant']) || is_string($cxn['perm']['grant']))) {
         return civicrm_api3_create_error('Connection has no permissions.');
     }
     $whitelist = \Civi\API\WhitelistRule::createAll($cxn['perm']['api']);
     \Civi::service('dispatcher')->addSubscriber(new \Civi\API\Subscriber\WhitelistSubscriber($whitelist));
     CRM_Core_Config::singleton()->userPermissionTemp = new CRM_Core_Permission_Temp();
     if ($cxn['perm']['grant'] === '*') {
         CRM_Core_Config::singleton()->userPermissionTemp->grant($SUPER_PERM);
     } else {
         CRM_Core_Config::singleton()->userPermissionTemp->grant($cxn['perm']['grant']);
     }
     $params['check_permissions'] = 'whitelist';
     return civicrm_api($entity, $action, $params);
 }
开发者ID:rameshrr99,项目名称:civicrm-core,代码行数:41,代码来源:ApiRouter.php

示例2: __construct

 /**
  * @param string $title
  *   Title of the page.
  * @param int $mode
  *   Mode of the page.
  * @param \CRM_Core_Resources|null $res
  *   Resource manager.
  */
 public function __construct($title = NULL, $mode = NULL, $res = NULL)
 {
     parent::__construct($title, $mode);
     $this->res = \CRM_Core_Resources::singleton();
     $this->angular = \Civi::service('angular');
     $this->region = \CRM_Utils_Request::retrieve('snippet', 'String') ? 'ajax-snippet' : 'html-header';
 }
开发者ID:FundingWorks,项目名称:civicrm-core,代码行数:15,代码来源:Main.php

示例3: civicrm_api3_generic_getActions

/**
 * Get available api actions.
 *
 * @param array $apiRequest
 *
 * @return array
 * @throws API_Exception
 */
function civicrm_api3_generic_getActions($apiRequest)
{
    civicrm_api3_verify_mandatory($apiRequest, NULL, array('entity'));
    $mfp = \Civi::service('magic_function_provider');
    $actions = $mfp->getActionNames($apiRequest['version'], $apiRequest['entity']);
    return civicrm_api3_create_success($actions, $apiRequest['params'], $apiRequest['entity'], 'getactions');
}
开发者ID:FundingWorks,项目名称:civicrm-core,代码行数:15,代码来源:Getactions.php

示例4: civicrm_api3

/**
 * Version 3 wrapper for civicrm_api.
 *
 * Throws exception.
 *
 * @param string $entity
 *   Type of entities to deal with.
 * @param string $action
 *   Create, get, delete or some special action name.
 * @param array $params
 *   Array to be passed to function.
 *
 * @throws CiviCRM_API3_Exception
 * @return array
 */
function civicrm_api3($entity, $action, $params = array())
{
    $params['version'] = 3;
    $result = \Civi::service('civi_api_kernel')->runSafe($entity, $action, $params);
    if (is_array($result) && !empty($result['is_error'])) {
        throw new CiviCRM_API3_Exception($result['error_message'], CRM_Utils_Array::value('error_code', $result, 'undefined'), $result);
    }
    return $result;
}
开发者ID:nielosz,项目名称:civicrm-core,代码行数:24,代码来源:api.php

示例5: setDefaultValues

 /**
  * This virtual function is used to set the default values of
  * various form elements
  *
  * access        public
  *
  * @return array
  *   reference to the array of default values
  */
 public function setDefaultValues()
 {
     // CRM-11761 retrieve user's activity filter preferences
     $defaults = array();
     $userID = CRM_Core_Session::getLoggedInContactID();
     if ($userID) {
         $defaults = Civi::service('settings_manager')->getBagByContact(NULL, $userID)->get('activity_tab_filter');
     }
     return $defaults;
 }
开发者ID:nielosz,项目名称:civicrm-core,代码行数:19,代码来源:ActivityFilter.php

示例6: setUp

 public function setUp()
 {
     $this->useTransaction(TRUE);
     parent::setUp();
     $this->modules = array('one' => new CRM_Core_Module('com.example.one', TRUE), 'two' => new CRM_Core_Module('com.example.two', TRUE));
     // Testing on drupal-demo fails because some extensions have mgd ents.
     CRM_Core_DAO::singleValueQuery('DELETE FROM civicrm_managed');
     $this->fixtures['com.example.one-foo'] = array('module' => 'com.example.one', 'name' => 'foo', 'entity' => 'CustomSearch', 'params' => array('version' => 3, 'class_name' => 'CRM_Example_One_Foo', 'is_reserved' => 1));
     $this->fixtures['com.example.one-bar'] = array('module' => 'com.example.one', 'name' => 'bar', 'entity' => 'CustomSearch', 'params' => array('version' => 3, 'class_name' => 'CRM_Example_One_Bar', 'is_reserved' => 1));
     $this->apiKernel = \Civi::service('civi_api_kernel');
     $this->adhocProvider = new \Civi\API\Provider\AdhocProvider(3, 'CustomSearch');
     $this->apiKernel->registerApiProvider($this->adhocProvider);
 }
开发者ID:konadave,项目名称:civicrm-core,代码行数:13,代码来源:ManagedEntitiesTest.php

示例7: formRule

 /**
  * @param $fields
  *
  * @return array|bool
  * @throws API_Exception
  */
 public static function formRule($fields)
 {
     $errors = array();
     require_once 'api/api.php';
     /** @var \Civi\API\Kernel $apiKernel */
     $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);
     } catch (\Civi\API\Exception\NotImplementedException $e) {
         $errors['api_action'] = ts('Given API command is not defined.');
     }
     if (!empty($errors)) {
         return $errors;
     }
     return empty($errors) ? TRUE : $errors;
 }
开发者ID:konadave,项目名称:civicrm-core,代码行数:23,代码来源:Job.php

示例8: get

 /**
  * Convert a callback expression to a valid PHP callback.
  *
  * @param string|array $id
  *   A callback expression; any of the following.
  *
  * @return array
  *   A PHP callback. Do not serialize (b/c it may include an object).
  * @throws \RuntimeException
  */
 public function get($id)
 {
     if (!is_string($id)) {
         // An array or object does not need to be further resolved.
         return $id;
     }
     if (strpos($id, '::') !== FALSE) {
         // Callback: Static method.
         return explode('::', $id);
     } elseif (strpos($id, '://') !== FALSE) {
         $url = parse_url($id);
         switch ($url['scheme']) {
             case 'obj':
                 // Object: Lookup in container.
                 return \Civi::service($url['host']);
             case 'call':
                 // Callback: Object/method in container.
                 $obj = \Civi::service($url['host']);
                 return array($obj, ltrim($url['path'], '/'));
             case 'api3':
                 // Callback: API.
                 return new ResolverApi($url);
             case 'global':
                 // Lookup in a global variable.
                 return new ResolverGlobalCallback($url['query'], $url['host'] . (isset($url['path']) ? rtrim($url['path'], '/') : ''));
             default:
                 throw new \RuntimeException("Unsupported callback scheme: " . $url['scheme']);
         }
     } elseif (in_array($id, array('0', '1'))) {
         // Callback: Constant value.
         return new ResolverConstantCallback((int) $id);
     } elseif ($id[0] >= 'A' && $id[0] <= 'Z') {
         // Object: New/default instance.
         return new $id();
     } else {
         // Callback: Function.
         return $id;
     }
 }
开发者ID:FundingWorks,项目名称:civicrm-core,代码行数:49,代码来源:Resolver.php

示例9: run

 /**
  * See class description.
  */
 public function run()
 {
     /**
      * @var \Civi\Angular\Manager $angular
      */
     $angular = \Civi::service('angular');
     $moduleNames = $this->parseModuleNames(\CRM_Utils_Request::retrieve('modules', 'String'), $angular);
     switch (\CRM_Utils_Request::retrieve('format', 'String')) {
         case 'json':
         case '':
             $this->send('application/javascript', json_encode($this->getMetadata($moduleNames, $angular)));
             break;
         case 'js':
             $this->send('application/javascript', $this->digestJs($angular->getResources($moduleNames, 'js', 'path')));
             break;
         case 'css':
             $this->send('text/css', \CRM_Utils_File::concat($angular->getResources($moduleNames, 'css', 'path'), "\n"));
             break;
         default:
             \CRM_Core_Error::fatal("Unrecognized format");
     }
     \CRM_Utils_System::civiExit();
 }
开发者ID:FundingWorks,项目名称:civicrm-core,代码行数:26,代码来源:Modules.php

示例10: rebuildMenuAndCaches

 /**
  * @param bool $triggerRebuild
  * @param bool $sessionReset
  *
  * @throws Exception
  */
 public static function rebuildMenuAndCaches($triggerRebuild = FALSE, $sessionReset = FALSE)
 {
     $config = CRM_Core_Config::singleton();
     $config->clearModuleList();
     // also cleanup all caches
     $config->cleanupCaches($sessionReset || CRM_Utils_Request::retrieve('sessionReset', 'Boolean', CRM_Core_DAO::$_nullObject, FALSE, 0, 'GET'));
     CRM_Core_Menu::store();
     // also reset navigation
     CRM_Core_BAO_Navigation::resetNavigation();
     // also cleanup module permissions
     $config->cleanupPermissions();
     // rebuild word replacement cache - pass false to prevent operations redundant with this fn
     CRM_Core_BAO_WordReplacement::rebuild(FALSE);
     Civi::service('settings_manager')->flush();
     // Clear js caches
     CRM_Core_Resources::singleton()->flushStrings()->resetCacheCode();
     CRM_Case_XMLRepository::singleton(TRUE);
     // also rebuild triggers if requested explicitly
     if ($triggerRebuild || CRM_Utils_Request::retrieve('triggerRebuild', 'Boolean', CRM_Core_DAO::$_nullObject, FALSE, 0, 'GET')) {
         CRM_Core_DAO::triggerRebuild();
     }
     CRM_Core_DAO_AllCoreTables::reinitializeCache(TRUE);
     CRM_Core_ManagedEntities::singleton(TRUE)->reconcile();
     //CRM-16257 update Config.IDS.ini might be an old copy
     CRM_Core_IDS::createConfigFile(TRUE);
 }
开发者ID:rameshrr99,项目名称:civicrm-core,代码行数:32,代码来源:Invoke.php

示例11: runJobs

 /**
  * Initiate all pending/ready jobs
  *
  * @param array $testParams
  * @param null $mode
  *
  * @return void
  */
 public static function runJobs($testParams = NULL, $mode = NULL)
 {
     $job = new CRM_Mailing_BAO_MailingJob();
     $config = CRM_Core_Config::singleton();
     $jobTable = CRM_Mailing_DAO_MailingJob::getTableName();
     $mailingTable = CRM_Mailing_DAO_Mailing::getTableName();
     if (!empty($testParams)) {
         $query = "\n      SELECT *\n        FROM {$jobTable}\n       WHERE id = {$testParams['job_id']}";
         $job->query($query);
     } else {
         $currentTime = date('YmdHis');
         $mailingACL = CRM_Mailing_BAO_Mailing::mailingACL('m');
         $domainID = CRM_Core_Config::domainID();
         $modeClause = 'AND m.sms_provider_id IS NULL';
         if ($mode == 'sms') {
             $modeClause = 'AND m.sms_provider_id IS NOT NULL';
         }
         // Select the first child job that is scheduled
         // CRM-6835
         $query = "\n      SELECT   j.*\n        FROM   {$jobTable}     j,\n           {$mailingTable} m\n       WHERE   m.id = j.mailing_id AND m.domain_id = {$domainID}\n                     {$modeClause}\n         AND   j.is_test = 0\n         AND   ( ( j.start_date IS null\n         AND       j.scheduled_date <= {$currentTime}\n         AND       j.status = 'Scheduled' )\n                OR     ( j.status = 'Running'\n         AND       j.end_date IS null ) )\n         AND (j.job_type = 'child')\n         AND   {$mailingACL}\n      ORDER BY j.mailing_id,\n           j.id\n      ";
         $job->query($query);
     }
     while ($job->fetch()) {
         // still use job level lock for each child job
         $lock = Civi::lockManager()->acquire("data.mailing.job.{$job->id}");
         if (!$lock->isAcquired()) {
             continue;
         }
         // for test jobs we do not change anything, since its on a short-circuit path
         if (empty($testParams)) {
             // we've got the lock, but while we were waiting and processing
             // other emails, this job might have changed under us
             // lets get the job status again and check
             $job->status = CRM_Core_DAO::getFieldValue('CRM_Mailing_DAO_MailingJob', $job->id, 'status', 'id', TRUE);
             if ($job->status != 'Running' && $job->status != 'Scheduled') {
                 // this includes Cancelled and other statuses, CRM-4246
                 $lock->release();
                 continue;
             }
         }
         /* Queue up recipients for the child job being launched */
         if ($job->status != 'Running') {
             $transaction = new CRM_Core_Transaction();
             // have to queue it up based on the offset and limits
             // get the parent ID, and limit and offset
             $job->queue($testParams);
             // Mark up the starting time
             $saveJob = new CRM_Mailing_DAO_MailingJob();
             $saveJob->id = $job->id;
             $saveJob->start_date = date('YmdHis');
             $saveJob->status = 'Running';
             $saveJob->save();
             $transaction->commit();
         }
         // Get the mailer
         if ($mode === NULL) {
             $mailer = \Civi::service('pear_mail');
         } elseif ($mode == 'sms') {
             $mailer = CRM_SMS_Provider::singleton(array('mailing_id' => $job->mailing_id));
         }
         // Compose and deliver each child job
         $isComplete = $job->deliver($mailer, $testParams);
         CRM_Utils_Hook::post('create', 'CRM_Mailing_DAO_Spool', $job->id, $isComplete);
         // Mark the child complete
         if ($isComplete) {
             /* Finish the job */
             $transaction = new CRM_Core_Transaction();
             $saveJob = new CRM_Mailing_DAO_MailingJob();
             $saveJob->id = $job->id;
             $saveJob->end_date = date('YmdHis');
             $saveJob->status = 'Complete';
             $saveJob->save();
             $transaction->commit();
             // don't mark the mailing as complete
         }
         // Release the child joblock
         $lock->release();
         if ($testParams) {
             return $isComplete;
         }
     }
 }
开发者ID:hoegrammer,项目名称:civicrm-core,代码行数:90,代码来源:MailingJob.php

示例12: caseChange

 /**
  * This hook fires whenever a record in a case changes.
  *
  * @param \Civi\CCase\Analyzer $analyzer
  */
 public static function caseChange(\Civi\CCase\Analyzer $analyzer)
 {
     $event = new \Civi\CCase\Event\CaseChangeEvent($analyzer);
     \Civi::service('dispatcher')->dispatch("hook_civicrm_caseChange", $event);
     return self::singleton()->invoke(1, $angularModules, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, 'civicrm_caseChange');
 }
开发者ID:rollox,项目名称:civicrm-core,代码行数:11,代码来源:Hook.php

示例13: getContactActivity

 public static function getContactActivity()
 {
     $contactID = CRM_Utils_Type::escape($_GET['cid'], 'Integer');
     $context = CRM_Utils_Type::escape(CRM_Utils_Array::value('context', $_GET), 'String');
     $sortMapper = array();
     foreach ($_GET['columns'] as $key => $value) {
         $sortMapper[$key] = $value['data'];
     }
     $offset = isset($_GET['start']) ? CRM_Utils_Type::escape($_GET['start'], 'Integer') : 0;
     $rowCount = isset($_GET['length']) ? CRM_Utils_Type::escape($_GET['length'], 'Integer') : 25;
     $sort = isset($_GET['order'][0]['column']) ? CRM_Utils_Array::value(CRM_Utils_Type::escape($_GET['order'][0]['column'], 'Integer'), $sortMapper) : NULL;
     $sortOrder = isset($_GET['order'][0]['dir']) ? CRM_Utils_Type::escape($_GET['order'][0]['dir'], 'String') : 'asc';
     $params = $_GET;
     if ($sort && $sortOrder) {
         $params['sortBy'] = $sort . ' ' . $sortOrder;
     }
     $params['page'] = $offset / $rowCount + 1;
     $params['rp'] = $rowCount;
     $params['contact_id'] = $contactID;
     $params['context'] = $context;
     // get the contact activities
     $activities = CRM_Activity_BAO_Activity::getContactActivitySelector($params);
     foreach ($activities as $key => $value) {
         //Check if recurring activity
         if (!empty($value['is_recurring_activity'])) {
             $repeat = $value['is_recurring_activity'];
             $activities[$key]['activity_type'] .= '<br/><span class="bold">' . ts('Repeating (%1 of %2)', array(1 => $repeat[0], 2 => $repeat[1])) . '</span>';
         }
     }
     // store the activity filter preference CRM-11761
     $session = CRM_Core_Session::singleton();
     $userID = $session->get('userID');
     if ($userID) {
         $activityFilter = array('activity_type_filter_id' => empty($params['activity_type_id']) ? '' : CRM_Utils_Type::escape($params['activity_type_id'], 'Integer'), 'activity_type_exclude_filter_id' => empty($params['activity_type_exclude_id']) ? '' : CRM_Utils_Type::escape($params['activity_type_exclude_id'], 'Integer'));
         /** @var \Civi\Core\SettingsBag $cSettings */
         $cSettings = Civi::service('settings_manager')->getBagByContact(CRM_Core_Config::domainID(), $userID);
         $cSettings->set('activity_tab_filter', $activityFilter);
     }
     CRM_Utils_JSON::output($activities);
 }
开发者ID:rameshrr99,项目名称:civicrm-core,代码行数:40,代码来源:AJAX.php

示例14: getMailer

 /**
  * Retrieve a mailer to send any mail from the application.
  *
  * @return Mail
  * @deprecated
  * @see Civi::service()
  */
 public static function getMailer()
 {
     return Civi::service('pear_mail');
 }
开发者ID:hyebahi,项目名称:civicrm-core,代码行数:11,代码来源:Config.php

示例15: triggerInfo

 /**
  * Get a list of triggers for the contact table.
  *
  * @see hook_civicrm_triggerInfo
  * @see CRM_Core_DAO::triggerRebuild
  * @see http://issues.civicrm.org/jira/browse/CRM-10554
  *
  * @param $info
  * @param null $tableName
  */
 public static function triggerInfo(&$info, $tableName = NULL)
 {
     //during upgrade, first check for valid version and then create triggers
     //i.e the columns created_date and modified_date are introduced in 4.3.alpha1 so dont create triggers for older version
     if (CRM_Core_Config::isUpgradeMode()) {
         $currentVer = CRM_Core_BAO_Domain::version(TRUE);
         //if current version is less than 4.3.alpha1 dont create below triggers
         if (version_compare($currentVer, '4.3.alpha1') < 0) {
             return;
         }
     }
     // Update timestamp for civicrm_contact itself
     if ($tableName == NULL || $tableName == self::getTableName()) {
         $info[] = array('table' => array(self::getTableName()), 'when' => 'BEFORE', 'event' => array('INSERT'), 'sql' => "\nSET NEW.created_date = CURRENT_TIMESTAMP;\n");
     }
     // Update timestamp when modifying closely related core tables
     $relatedTables = array('civicrm_address', 'civicrm_email', 'civicrm_im', 'civicrm_phone', 'civicrm_website');
     self::generateTimestampTriggers($info, $tableName, $relatedTables, 'contact_id');
     // Update timestamp when modifying related custom-data tables
     $customGroupTables = array();
     $customGroupDAO = CRM_Core_BAO_CustomGroup::getAllCustomGroupsByBaseEntity('Contact');
     $customGroupDAO->is_multiple = 0;
     $customGroupDAO->find();
     while ($customGroupDAO->fetch()) {
         $customGroupTables[] = $customGroupDAO->table_name;
     }
     if (!empty($customGroupTables)) {
         self::generateTimestampTriggers($info, $tableName, $customGroupTables, 'entity_id');
     }
     // Update phone table to populate phone_numeric field
     if (!$tableName || $tableName == 'civicrm_phone') {
         // Define stored sql function needed for phones
         $sqlTriggers = Civi::service('sql_triggers');
         $sqlTriggers->enqueueQuery(self::DROP_STRIP_FUNCTION_43);
         $sqlTriggers->enqueueQuery(self::CREATE_STRIP_FUNCTION_43);
         $info[] = array('table' => array('civicrm_phone'), 'when' => 'BEFORE', 'event' => array('INSERT', 'UPDATE'), 'sql' => "\nSET NEW.phone_numeric = civicrm_strip_non_numeric(NEW.phone);\n");
     }
 }
开发者ID:nielosz,项目名称:civicrm-core,代码行数:48,代码来源:Contact.php


注:本文中的Civi::service方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。