當前位置: 首頁>>代碼示例>>PHP>>正文


PHP CRM_Utils_Hook::singleton方法代碼示例

本文整理匯總了PHP中CRM_Utils_Hook::singleton方法的典型用法代碼示例。如果您正苦於以下問題:PHP CRM_Utils_Hook::singleton方法的具體用法?PHP CRM_Utils_Hook::singleton怎麽用?PHP CRM_Utils_Hook::singleton使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在CRM_Utils_Hook的用法示例。


在下文中一共展示了CRM_Utils_Hook::singleton方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testHookAlterMailer

 public function testHookAlterMailer()
 {
     $test = $this;
     $mockMailer = new CRM_Utils_FakeObject(array('send' => function ($recipients, $headers, $body) use($test) {
         $test->calls['send']++;
         $test->assertEquals(array('to@example.org'), $recipients);
         $test->assertEquals('Subject Example', $headers['Subject']);
     }));
     CRM_Utils_Hook::singleton()->setHook('civicrm_alterMailer', function (&$mailer, $driver, $params) use($test, $mockMailer) {
         $test->calls['civicrm_alterMailer']++;
         $test->assertTrue(is_string($driver) && !empty($driver));
         $test->assertTrue(is_array($params));
         $test->assertTrue(is_callable(array($mailer, 'send')));
         $mailer = $mockMailer;
     });
     $params = array();
     $params['groupName'] = 'CRM_Core_Config_MailerTest';
     $params['from'] = 'From Example <from@example.com>';
     $params['toName'] = 'To Example';
     $params['toEmail'] = 'to@example.org';
     $params['subject'] = 'Subject Example';
     $params['text'] = 'Example text';
     $params['html'] = '<p>Example HTML</p>';
     CRM_Utils_Mail::send($params);
     $this->assertEquals(1, $this->calls['civicrm_alterMailer']);
     $this->assertEquals(1, $this->calls['send']);
     // once more, just to make sure the hooks are called right #times
     CRM_Utils_Mail::send($params);
     CRM_Utils_Mail::send($params);
     $this->assertEquals(1, $this->calls['civicrm_alterMailer']);
     $this->assertEquals(3, $this->calls['send']);
 }
開發者ID:konadave,項目名稱:civicrm-core,代碼行數:32,代碼來源:MailerTest.php

示例2: tearDown

 /**
  *
  */
 function tearDown()
 {
     $this->_mut->stop();
     $this->quickCleanup(array('civicrm_mailing', 'civicrm_mailing_job', 'civicrm_contact'));
     CRM_Utils_Hook::singleton()->reset();
     parent::tearDown();
 }
開發者ID:prashantgajare,項目名稱:civicrm-core,代碼行數:10,代碼來源:JobProcessMailingTest.php

示例3: tearDown

 function tearDown()
 {
     $this->quickCleanup(array('civicrm_job', 'civicrm_action_log', 'civicrm_action_schedule'));
     $this->quickCleanUpFinancialEntities();
     CRM_Utils_Hook::singleton()->reset();
     parent::tearDown();
 }
開發者ID:prashantgajare,項目名稱:civicrm-core,代碼行數:7,代碼來源:JobTest.php

示例4: tearDown

 public function tearDown()
 {
     CRM_Utils_Hook::singleton()->reset();
     parent::tearDown();
     $this->callAPISuccess('system', 'flush', array());
     $this->quickCleanup(array('civicrm_domain'));
 }
開發者ID:nganivet,項目名稱:civicrm-core,代碼行數:7,代碼來源:SettingTest.php

示例5: testHookCron

 public function testHookCron()
 {
     $hook = $this->getMock('stdClass', array('civicrm_cron'));
     $hook->expects($this->once())->method('civicrm_cron')->with($this->isInstanceOf('CRM_Core_JobManager'));
     CRM_Utils_Hook::singleton()->setMock($hook);
     $jobManager = new CRM_Core_JobManager();
     $jobManager->execute(FALSE);
 }
開發者ID:sdekok,項目名稱:civicrm-core,代碼行數:8,代碼來源:JobManagerTest.php

示例6: tearDown

 /**
  * (non-PHPdoc)
  * @see CiviUnitTestCase::tearDown()
  */
 public function tearDown()
 {
     CRM_Utils_Hook::singleton()->reset();
     $tablesToTruncate = array('civicrm_contact', 'civicrm_group_contact', 'civicrm_group', 'civicrm_acl', 'civicrm_acl_cache', 'civicrm_acl_entity_role', 'civicrm_acl_contact_cache', 'civicrm_contribution', 'civicrm_participant', 'civicrm_uf_match');
     $this->quickCleanup($tablesToTruncate);
     $config = CRM_Core_Config::singleton();
     unset($config->userPermissionClass->permissions);
 }
開發者ID:sdekok,項目名稱:civicrm-core,代碼行數:12,代碼來源:ACLPermissionTest.php

示例7: tearDown

 public function tearDown()
 {
     CRM_Utils_Hook::singleton()->reset();
     $this->quickCleanup(array('civicrm_group'));
     $config = CRM_Core_Config::singleton();
     unset($config->userPermissionClass->permissions);
     parent::tearDown();
 }
開發者ID:vakeesan26,項目名稱:civicrm-core,代碼行數:8,代碼來源:AjaxTest.php

示例8: tearDown

 /**
  * (non-PHPdoc)
  * @see CiviUnitTestCase::tearDown()
  */
 function tearDown()
 {
     CRM_Utils_Hook::singleton()->reset();
     $tablesToTruncate = array('civicrm_contact');
     $this->quickCleanup($tablesToTruncate);
     $config = CRM_Core_Config::singleton();
     unset($config->userPermissionClass->permissions);
 }
開發者ID:archcidburnziso,項目名稱:civicrm-core,代碼行數:12,代碼來源:ACLPermissionTest.php

示例9: pdf_shared_token

 /**
  * This hook is called once for every batch before the pdf template is rendered.
  * You should use this for performance reasons when the token can be shared between chunk items (for example a contact
  * address that is the same for all files)
  *
  * You can implement this hook to add/modify template tokens
  * e.g. in your hook implementation call $template->assign('myCustomToken', 'my custom token');
  * and place a token called {$myCustomToken} in the template.
  *
  * @param object $template
  *
  * @return mixed based on op. pre-hooks return a boolean or
  * an error message which aborts the operation
  * @access public
  */
 static function pdf_shared_token(&$template, &$chunk)
 {
     if (version_compare(CRM_Utils_System::version(), '4.5', '<')) {
         return CRM_Utils_Hook::singleton()->invoke(1, $template, $chunk_item, self::$null, self::$null, self::$null, 'civicrm_pdf_shared_token');
     } else {
         return CRM_Utils_Hook::singleton()->invoke(1, $template, $chunk_item, self::$null, self::$null, self::$null, self::$null, 'civicrm_pdf_shared_token');
     }
 }
開發者ID:systopia,項目名稱:de.systopia.donrec,代碼行數:23,代碼來源:DonrecCustomisationHooks.php

示例10: tearDown

 /**
  */
 public function tearDown()
 {
     $this->_mut->stop();
     //    $this->quickCleanup(array('civicrm_mailing', 'civicrm_mailing_job', 'civicrm_contact'));
     CRM_Utils_Hook::singleton()->reset();
     CRM_Mailing_BAO_MailingJob::$mailsProcessed = 0;
     // DGW
     parent::tearDown();
 }
開發者ID:vakeesan26,項目名稱:civicrm-core,代碼行數:11,代碼來源:JobProcessMailingTest.php

示例11: mapAccountsData

 /**
  * This hook data transforms data stored in accounts_data to be formatted into a standard format.
  *
  * The called hook is expected to add a key 'civicrm_formatted' to the accountsData array
  * with the data using the same field names as the relevant CiviCRM api.
  *
  * @param array $accountsData data from accounts system
  * @param string $entity entity - eg. 'AccountContact'
  * @param string $plugin plugin in use
  *
  * @return mixed
  *   Ignore value.
  */
 public static function mapAccountsData(&$accountsData, $entity, $plugin)
 {
     $codeVersion = explode('.', CRM_Utils_System::version());
     if (version_compare($codeVersion[0] . '.' . $codeVersion[1], 4.5) >= 0) {
         return CRM_Utils_Hook::singleton()->invoke(3, $accountsData, $entity, $plugin, CRM_Core_DAO::$_nullObject, CRM_Core_DAO::$_nullObject, CRM_Core_DAO::$_nullObject, 'civicrm_mapAccountsData');
     } else {
         return CRM_Utils_Hook::singleton()->invoke(3, $accountsData, $entity, $plugin, CRM_Core_DAO::$_nullObject, CRM_Core_DAO::$_nullObject, 'civicrm_mapAccountsData');
     }
 }
開發者ID:kidaa30,項目名稱:yes,代碼行數:22,代碼來源:Hook.php

示例12: invoke

 private function invoke($fnSuffix, $numParams, &$arg1 = null, &$arg2 = null, &$arg3 = null, &$arg4 = null, &$arg5 = null)
 {
     $hook = CRM_Utils_Hook::singleton();
     $civiVersion = CRM_Core_BAO_Domain::version();
     if (version_compare('4.4', $civiVersion, '<=')) {
         //in CiviCRM 4.4 the invoke function has 5 arguments maximum
         return $hook->invoke($numParams, $arg1, $arg2, $arg3, $arg4, $arg5, $fnSuffix);
     }
     //in CiviCRM 4.5 and later the invoke function has 6 arguments
     return $hook->invoke($numParams, $arg1, $arg2, $arg3, $arg4, $arg5, null, $fnSuffix);
 }
開發者ID:alejandro-ixiam,項目名稱:org.civicoop.civirules,代碼行數:11,代碼來源:HookInvoker.php

示例13: setUp

 public function setUp()
 {
     parent::setUp();
     /** @var $hooks \CRM_Utils_Hook_UnitTests */
     $hooks = \CRM_Utils_Hook::singleton();
     $hooks->setHook('civicrm_caseTypes', array($this, 'hook_caseTypes'));
     \CRM_Case_XMLRepository::singleton(TRUE);
     \CRM_Case_XMLProcessor::flushStaticCaches();
     // CRM-9404 - set-up is a bit cumbersome but had to put something in place to set up activity types & case types
     //. Using XML was causing breakage as id numbers were changing over time
     // & was really hard to troubleshoot as involved truncating option_value table to mitigate this & not leaving DB in a
     // state where tests could run afterwards without re-loading.
     $this->caseStatusGroup = $this->callAPISuccess('option_group', 'get', array('name' => 'case_status', 'format.only_id' => 1));
     $optionValues = array('Medical evaluation' => 'Medical evaluation', 'Mental health evaluation' => "Mental health evaluation", 'Secure temporary housing' => 'Secure temporary housing', 'Long-term housing plan' => 'Long-term housing plan', 'ADC referral' => 'ADC referral', 'Income and benefits stabilization' => 'Income and benefits stabilization');
     foreach ($optionValues as $name => $label) {
         $activityTypes = $this->callAPISuccess('option_value', 'Create', array('option_group_id' => 2, 'name' => $name, 'label' => $label, 'component_id' => 7));
         // store for cleanup
         $this->optionValues[] = $activityTypes['id'];
     }
     // We used to be inconsistent about "HousingSupport" vs "housing_support".
     // Now, the rule is simply: use the "name" from "civicrm_case_type.name".
     $this->caseType = 'housing_support';
     $this->caseTypeId = 1;
     $this->tablesToTruncate = array('civicrm_activity', 'civicrm_contact', 'civicrm_custom_group', 'civicrm_custom_field', 'civicrm_case', 'civicrm_case_contact', 'civicrm_case_activity', 'civicrm_case_type', 'civicrm_activity_contact', 'civicrm_managed', 'civicrm_relationship', 'civicrm_relationship_type');
     $this->quickCleanup($this->tablesToTruncate);
     $this->loadAllFixtures();
     // enable the default custom templates for the case type xml files
     $this->customDirectories(array('template_path' => TRUE));
     // case is not enabled by default
     $enableResult = CRM_Core_BAO_ConfigSetting::enableComponent('CiviCase');
     $this->assertTrue($enableResult, 'Cannot enable CiviCase in line ' . __LINE__);
     // create a logged in USER since the code references it for source_contact_id
     $this->createLoggedInUser();
     $session = CRM_Core_Session::singleton();
     $this->_loggedInUser = $session->get('userID');
     /// note that activityType options are cached by the FULL set of options you pass in
     // ie. because Activity api includes campaign in it's call cache is not flushed unless
     // included in this call. Also note flush function doesn't work on this property as it sets to null not empty array
     CRM_Core_PseudoConstant::activityType(TRUE, TRUE, TRUE, 'name', TRUE);
 }
開發者ID:prashantgajare,項目名稱:civicrm-core,代碼行數:40,代碼來源:CiviCaseTestCase.php

示例14: setUp

 public function setUp()
 {
     parent::setUp();
     CRM_Utils_Hook::singleton()->setHook('civicrm_fieldOptions', array($this, 'hook_civicrm_fieldOptions'));
 }
開發者ID:kcristiano,項目名稱:civicrm-core,代碼行數:5,代碼來源:FieldOptionsTest.php

示例15: clearModuleList

 /**
  * Flush information about loaded modules.
  */
 public function clearModuleList()
 {
     CRM_Extension_System::singleton()->getCache()->flush();
     CRM_Utils_Hook::singleton(TRUE);
     CRM_Core_PseudoConstant::getModuleExtensions(TRUE);
     CRM_Core_Module::getAll(TRUE);
 }
開發者ID:kcristiano,項目名稱:civicrm-core,代碼行數:10,代碼來源:Config.php


注:本文中的CRM_Utils_Hook::singleton方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。