本文整理汇总了PHP中CRM_Utils_Array::subset方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Utils_Array::subset方法的具体用法?PHP CRM_Utils_Array::subset怎么用?PHP CRM_Utils_Array::subset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Utils_Array
的用法示例。
在下文中一共展示了CRM_Utils_Array::subset方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct()
{
$tokens = CRM_Utils_Array::subset(CRM_Utils_Array::collect('title', CRM_Contribute_DAO_Contribution::fields()), $this->getPassthruTokens());
$tokens['id'] = ts('Contribution ID');
$tokens['payment_instrument'] = ts('Payment Instrument');
$tokens['source'] = ts('Contribution Source');
$tokens['status'] = ts('Contribution Status');
$tokens['type'] = ts('Financial Type');
parent::__construct('contribution', $tokens);
}
示例2: civicrm_api3_mailing_a_b_submit
/**
* Send A/B mail to A/B recipients respectively.
*
* @param array $params
*
* @return array
* @throws API_Exception
*/
function civicrm_api3_mailing_a_b_submit($params)
{
civicrm_api3_verify_mandatory($params, 'CRM_Mailing_DAO_MailingAB', array('id', 'status'));
if (!isset($params['scheduled_date']) && !isset($updateParams['approval_date'])) {
throw new API_Exception("Missing parameter scheduled_date and/or approval_date");
}
$dao = new CRM_Mailing_DAO_MailingAB();
$dao->id = $params['id'];
if (!$dao->find(TRUE)) {
throw new API_Exception("Failed to locate A/B test by ID");
}
if (empty($dao->mailing_id_a) || empty($dao->mailing_id_b) || empty($dao->mailing_id_c)) {
throw new API_Exception("Missing mailing IDs for A/B test");
}
$submitParams = CRM_Utils_Array::subset($params, array('scheduled_date', 'approval_date', 'approval_note', 'approval_status_id'));
switch ($params['status']) {
case 'Testing':
if (!empty($dao->status) && $dao->status != 'Draft') {
throw new API_Exception("Cannot transition to state 'Testing'");
}
civicrm_api3('Mailing', 'submit', $submitParams + array('id' => $dao->mailing_id_a, '_skip_evil_bao_auto_recipients_' => 0));
civicrm_api3('Mailing', 'submit', $submitParams + array('id' => $dao->mailing_id_b, '_skip_evil_bao_auto_recipients_' => 1));
CRM_Mailing_BAO_MailingAB::distributeRecipients($dao);
break;
case 'Final':
if ($dao->status != 'Testing') {
throw new API_Exception("Cannot transition to state 'Final'");
}
civicrm_api3('Mailing', 'submit', $submitParams + array('id' => $dao->mailing_id_c, '_skip_evil_bao_auto_recipients_' => 1));
break;
default:
throw new API_Exception("Unrecognized submission status");
}
return civicrm_api3('MailingAB', 'create', array('id' => $dao->id, 'status' => $params['status'], 'options' => array('reload' => 1)));
}
示例3: testConcurrency
/**
* Setup various mail configuration options (eg $mailerBatchLimit,
* $mailerJobMax) and spawn multiple worker threads ($workers).
* Allow the threads to complete. (Optionally, repeat the above
* process.) Finally, check to see if the right number of
* jobs delivered the right number of messages.
*
* @param array $settings
* An array of settings (eg mailerBatchLimit, workers). See comments
* for $this->defaultSettings.
* @param array $expectedTallies
* A listing of the number cron-runs keyed by their size.
* For example, array(10=>2) means that there 2 cron-runs
* which delivered 10 messages each.
* @param int $expectedTotal
* The total number of contacts for whom messages should have
* been sent.
* @dataProvider concurrencyExamples
*/
public function testConcurrency($settings, $expectedTallies, $expectedTotal)
{
$settings = array_merge($this->defaultSettings, $settings);
$this->createContactsInGroup($settings['recipients'], $this->_groupID);
Civi::settings()->add(CRM_Utils_Array::subset($settings, array('mailerBatchLimit', 'mailerJobsMax', 'mailThrottleTime')));
$this->callAPISuccess('mailing', 'create', $this->_params);
$this->_mut->assertRecipients(array());
$allApiResults = array();
for ($iterationId = 0; $iterationId < $settings['iterations']; $iterationId++) {
$apiCalls = $this->createExternalAPI();
$apiCalls->addEnv(array('CIVICRM_CRON_HOLD' => $settings['lockHold']));
for ($workerId = 0; $workerId < $settings['workers']; $workerId++) {
$apiCalls->addCall('job', 'process_mailing', array());
}
$apiCalls->start();
$this->assertEquals($settings['workers'], $apiCalls->getRunningCount());
$apiCalls->wait();
$allApiResults = array_merge($allApiResults, $apiCalls->getResults());
}
$actualTallies = $this->tallyApiResults($allApiResults);
$this->assertEquals($expectedTallies, $actualTallies, 'API tallies should match.' . print_r(array('expectedTallies' => $expectedTallies, 'actualTallies' => $actualTallies, 'apiResults' => $allApiResults), TRUE));
$this->_mut->assertRecipients($this->getRecipients(1, $expectedTotal));
$this->assertEquals(0, $apiCalls->getRunningCount());
}
示例4: array
/**
* Retrieve list of Scheduled Reminders.
*
* @param bool $namesOnly
* Return simple list of names.
*
* @param \Civi\ActionSchedule\Mapping|NULL $filterMapping
* Filter by the schedule's mapping type.
* @param int $filterValue
* Filter by the schedule's entity_value.
*
* @return array
* (reference) reminder list
*/
public static function &getList($namesOnly = FALSE, $filterMapping = NULL, $filterValue = NULL)
{
$query = "\nSELECT\n title,\n cas.id as id,\n cas.mapping_id,\n cas.entity_value as entityValueIds,\n cas.entity_status as entityStatusIds,\n cas.start_action_date as entityDate,\n cas.start_action_offset,\n cas.start_action_unit,\n cas.start_action_condition,\n cas.absolute_date,\n is_repeat,\n is_active\n\nFROM civicrm_action_schedule cas\n";
$queryParams = array();
$where = " WHERE 1 ";
if ($filterMapping and $filterValue) {
$where .= " AND cas.entity_value = %1 AND cas.mapping_id = %2";
$queryParams[1] = array($filterValue, 'Integer');
$queryParams[2] = array($filterMapping->getId(), 'String');
}
$where .= " AND cas.used_for IS NULL";
$query .= $where;
$dao = CRM_Core_DAO::executeQuery($query, $queryParams);
while ($dao->fetch()) {
/** @var Civi\ActionSchedule\Mapping $filterMapping */
$filterMapping = CRM_Utils_Array::first(self::getMappings(array('id' => $dao->mapping_id)));
$list[$dao->id]['id'] = $dao->id;
$list[$dao->id]['title'] = $dao->title;
$list[$dao->id]['start_action_offset'] = $dao->start_action_offset;
$list[$dao->id]['start_action_unit'] = $dao->start_action_unit;
$list[$dao->id]['start_action_condition'] = $dao->start_action_condition;
$list[$dao->id]['entityDate'] = ucwords(str_replace('_', ' ', $dao->entityDate));
$list[$dao->id]['absolute_date'] = $dao->absolute_date;
$list[$dao->id]['entity'] = $filterMapping->getLabel();
$list[$dao->id]['value'] = implode(', ', CRM_Utils_Array::subset($filterMapping->getValueLabels(), explode(CRM_Core_DAO::VALUE_SEPARATOR, $dao->entityValueIds)));
$list[$dao->id]['status'] = implode(', ', CRM_Utils_Array::subset($filterMapping->getStatusLabels($dao->entityValueIds), explode(CRM_Core_DAO::VALUE_SEPARATOR, $dao->entityStatusIds)));
$list[$dao->id]['is_repeat'] = $dao->is_repeat;
$list[$dao->id]['is_active'] = $dao->is_active;
}
return $list;
}