*/
function cv($cmd, $decode = 'json') {
$cmd = 'cv ' . $cmd;
- $descriptorSpec = array(0 => array("pipe", "r"), 1 => array("pipe", "w"), 2 => STDERR);
+ $descriptorSpec = [0 => ["pipe", "r"], 1 => ["pipe", "w"], 2 => STDERR];
$oldOutput = getenv('CV_OUTPUT');
putenv("CV_OUTPUT=json");
*/
function cv($cmd, $decode = 'json') {
$cmd = 'cv ' . $cmd;
- $descriptorSpec = array(0 => array("pipe", "r"), 1 => array("pipe", "w"), 2 => STDERR);
+ $descriptorSpec = [0 => ["pipe", "r"], 1 => ["pipe", "w"], 2 => STDERR];
$oldOutput = getenv('CV_OUTPUT');
putenv("CV_OUTPUT=json");
*/
function cv($cmd, $decode = 'json') {
$cmd = 'cv ' . $cmd;
- $descriptorSpec = array(0 => array("pipe", "r"), 1 => array("pipe", "w"), 2 => STDERR);
+ $descriptorSpec = [0 => ["pipe", "r"], 1 => ["pipe", "w"], 2 => STDERR];
$oldOutput = getenv('CV_OUTPUT');
putenv("CV_OUTPUT=json");
*/
function cv($cmd, $decode = 'json') {
$cmd = 'cv ' . $cmd;
- $descriptorSpec = array(0 => array("pipe", "r"), 1 => array("pipe", "w"), 2 => STDERR);
+ $descriptorSpec = [0 => ["pipe", "r"], 1 => ["pipe", "w"], 2 => STDERR];
$oldOutput = getenv('CV_OUTPUT');
putenv("CV_OUTPUT=json");
*/
function cv($cmd, $decode = 'json') {
$cmd = 'cv ' . $cmd;
- $descriptorSpec = array(0 => array("pipe", "r"), 1 => array("pipe", "w"), 2 => STDERR);
+ $descriptorSpec = [0 => ["pipe", "r"], 1 => ["pipe", "w"], 2 => STDERR];
$oldOutput = getenv('CV_OUTPUT');
putenv("CV_OUTPUT=json");
*/
function cv($cmd, $decode = 'json') {
$cmd = 'cv ' . $cmd;
- $descriptorSpec = array(0 => array("pipe", "r"), 1 => array("pipe", "w"), 2 => STDERR);
+ $descriptorSpec = [0 => ["pipe", "r"], 1 => ["pipe", "w"], 2 => STDERR];
$oldOutput = getenv('CV_OUTPUT');
putenv("CV_OUTPUT=json");
$job->mailing_id = $mailing->id ?: NULL;
$job->status = 'Complete';
- $flexMailer = new FlexMailer(array(
+ $flexMailer = new FlexMailer([
'is_preview' => TRUE,
'mailing' => $mailing,
'job' => $job,
'attachments' => \CRM_Core_BAO_File::getEntityFile('civicrm_mailing',
$mailing->id),
- ));
+ ]);
if (count($flexMailer->validate()) > 0) {
throw new \CRM_Core_Exception("FlexMailer cannot execute: invalid context");
$task = new FlexMailerTask($job->id, $contactID, 'fakehash',
'placeholder@example.com');
- $flexMailer->fireComposeBatch(array($task));
+ $flexMailer->fireComposeBatch([$task]);
- return civicrm_api3_create_success(array(
+ return civicrm_api3_create_success([
'id' => isset($params['id']) ? $params['id'] : NULL,
'contact_id' => $contactID,
'subject' => $task->getMailParam('Subject'),
'body_text' => $task->getMailParam('text'),
// Flag our role in processing this - to support tests.
'_rendered_by_' => 'flexmailer',
- ));
+ ]);
}
}
* Ex: array('subject' => 'The Subject field is blank').
* Example keys: 'subject', 'name', 'from_name', 'from_email', 'body', 'body_html:unsubscribeUrl'.
*/
- protected $errors = array();
+ protected $errors = [];
/**
* CheckSendableEvent constructor.
* Array(string $event => string $class).
*/
public static function getEventTypes() {
- return array(
+ return [
self::EVENT_RUN => 'Civi\\FlexMailer\\Event\\RunEvent',
self::EVENT_WALK => 'Civi\\FlexMailer\\Event\\WalkBatchesEvent',
self::EVENT_COMPOSE => 'Civi\\FlexMailer\\Event\\ComposeBatchEvent',
self::EVENT_SEND => 'Civi\\FlexMailer\\Event\\SendBatchEvent',
- );
+ ];
}
/**
* TRUE if delivery completed.
*/
public static function createAndRun($job, $deprecatedMessageMailer, $deprecatedTestParams) {
- $flexMailer = new \Civi\FlexMailer\FlexMailer(array(
+ $flexMailer = new \Civi\FlexMailer\FlexMailer([
'mailing' => \CRM_Mailing_BAO_Mailing::findById($job->mailing_id),
'job' => $job,
'attachments' => \CRM_Core_BAO_File::getEntityFile('civicrm_mailing', $job->mailing_id),
'deprecatedMessageMailer' => $deprecatedMessageMailer,
'deprecatedTestParams' => $deprecatedTestParams,
- ));
+ ]);
return $flexMailer->run();
}
* - attachments: array
* @param \Symfony\Component\EventDispatcher\EventDispatcherInterface $dispatcher
*/
- public function __construct($context = array(), EventDispatcherInterface $dispatcher = NULL) {
+ public function __construct($context = [], EventDispatcherInterface $dispatcher = NULL) {
$this->context = $context;
$this->dispatcher = $dispatcher ?: \Civi::service('dispatcher');
}
* List of error messages
*/
public function validate() {
- $errors = array();
+ $errors = [];
if (empty($this->context['mailing'])) {
$errors['mailing'] = 'Missing \"mailing\"';
}
* @see MailParams
* @see \CRM_Utils_Hook::alterMailParams()
*/
- private $mailParams = array();
+ private $mailParams = [];
/**
* FlexMailerTask constructor.
$e->getJob()->id, $task->getEventQueueId(), $task->getHash(),
$task->getAddress());
- $mailParams = array();
+ $mailParams = [];
$mailParams['List-Unsubscribe'] = "<mailto:{$verp['unsubscribe']}>";
\CRM_Mailing_BAO_Mailing::addMessageIdHeader($mailParams, 'm', $e->getJob()->id, $task->getEventQueueId(), $task->getHash());
$mailParams['Precedence'] = 'bulk';
$mailerBatchLimit = \CRM_Core_Config::singleton()->mailerBatchLimit;
$eq = \CRM_Mailing_BAO_MailingJob::findPendingTasks($job->id, 'email');
- $tasks = array();
+ $tasks = [];
while ($eq->fetch()) {
if ($mailerBatchLimit > 0 && \CRM_Mailing_BAO_MailingJob::$mailsProcessed >= $mailerBatchLimit) {
if (!empty($tasks)) {
$e->setCompleted($isDelivered);
return;
}
- $tasks = array();
+ $tasks = [];
}
}
* @return array
*/
public function createTokenProcessorContext(ComposeBatchEvent $e) {
- $context = array(
+ $context = [
'controller' => get_class($this),
// FIXME: Use template_type, template_options
'smarty' => defined('CIVICRM_MAIL_SMARTY') && CIVICRM_MAIL_SMARTY ? TRUE : FALSE,
'mailing' => $e->getMailing(),
'mailingId' => $e->getMailing()->id,
- );
+ ];
return $context;
}
ComposeBatchEvent $e,
FlexMailerTask $task
) {
- return array(
+ return [
'contactId' => $task->getContactId(),
'mailingJobId' => $e->getJob()->id,
- 'mailingActionTarget' => array(
+ 'mailingActionTarget' => [
'id' => $task->getEventQueueId(),
'hash' => $task->getHash(),
'email' => $task->getAddress(),
- ),
+ ],
'flexMailerTask' => $task,
- );
+ ];
}
/**
FlexMailerTask $task,
TokenRow $row
) {
- return array(
+ return [
'Subject' => $row->render('subject'),
'text' => $row->render('body_text'),
'html' => $row->render('body_html'),
- );
+ ];
}
/**
$job_date = \CRM_Utils_Date::isoToMysql($job->scheduled_date);
$mailer = \Civi::service('pear_mail');
- $targetParams = $deliveredParams = array();
+ $targetParams = $deliveredParams = [];
$count = 0;
$retryBatch = FALSE;
* @param string $errorMessage
*/
protected function recordBounce($job, $task, $errorMessage) {
- $params = array(
+ $params = [
'event_queue_id' => $task->getEventQueueId(),
'job_id' => $job->id,
'hash' => $task->getHash(),
- );
+ ];
$params = array_merge($params,
\CRM_Mailing_BAO_BouncePattern::match($errorMessage)
);
}
if (!$found) {
- $e->setError($field, E::ts('Field %1 is required.', array(
+ $e->setError($field, E::ts('Field %1 is required.', [
1 => $fieldTitle,
- )));
+ ]));
}
unset($found);
}
return;
}
- foreach (array('body_html', 'body_text') as $field) {
+ foreach (['body_html', 'body_text'] as $field) {
$str = $e->getFullBody($field);
if (empty($str)) {
continue;
}
foreach ($this->findMissingTokens($str) as $token => $desc) {
$e->setError("{$field}:{$token}", E::ts('This message is missing a required token - {%1}: %2',
- array(1 => $token, 2 => $desc)
+ [1 => $token, 2 => $desc]
));
}
}
}
public function findMissingTokens($str) {
- $missing = array();
+ $missing = [];
foreach ($this->getRequiredTokens() as $token => $value) {
if (!is_array($value)) {
if (!preg_match('/(^|[^\{])' . preg_quote('{' . $token . '}') . '/', $str)) {
*/
public static function byColumn(ComposeBatchEvent $e, $field, $filter) {
$tasks = $e->getTasks();
- $values = array();
+ $values = [];
foreach ($tasks as $k => $task) {
/** @var \Civi\FlexMailer\FlexMailerTask $task */
}
}
- $values = call_user_func_array($filter, array($values, $e));
+ $values = call_user_func_array($filter, [$values, $e]);
foreach ($values as $k => $value) {
$tasks[$k]->setMailParam($field, $value);
* Array(int $contactId => string $displayName).
*/
protected function getContactNames($tasks) {
- $ids = array();
+ $ids = [];
foreach ($tasks as $task) {
/** @var \Civi\FlexMailer\FlexMailerTask $task */
$ids[$task->getContactId()] = $task->getContactId();
$ids = array_filter($ids, 'is_numeric');
if (empty($ids)) {
- return array();
+ return [];
}
$idString = implode(',', $ids);
$query = \CRM_Core_DAO::executeQuery(
"SELECT id, display_name FROM civicrm_contact WHERE id in ($idString)");
- $names = array();
+ $names = [];
while ($query->fetch()) {
$names[$query->id] = $query->display_name;
}
break;
default:
- $message->headers(array($key => $value), TRUE);
+ $message->headers([$key => $value], TRUE);
}
}
$apiOverrides = $container->setDefinition('civi_flexmailer_api_overrides', new Definition('Civi\API\Provider\ProviderInterface'))->setPublic(TRUE);
self::applyStaticFactory($apiOverrides, __CLASS__, 'createApiOverrides');
- $container->setDefinition('civi_flexmailer_required_fields', new Definition('Civi\FlexMailer\Listener\RequiredFields', array(
- array(
+ $container->setDefinition('civi_flexmailer_required_fields', new Definition('Civi\FlexMailer\Listener\RequiredFields', [
+ [
'subject',
'name',
'from_name',
'from_email',
'(body_html|body_text)',
- ),
- )))->setPublic(TRUE);
- $container->setDefinition('civi_flexmailer_required_tokens', new Definition('Civi\FlexMailer\Listener\RequiredTokens', array(
- array('traditional'),
- array(
+ ],
+ ]))->setPublic(TRUE);
+ $container->setDefinition('civi_flexmailer_required_tokens', new Definition('Civi\FlexMailer\Listener\RequiredTokens', [
+ ['traditional'],
+ [
'domain.address' => ts("Domain address - displays your organization's postal address."),
- 'action.optOutUrl or action.unsubscribeUrl' => array(
+ 'action.optOutUrl or action.unsubscribeUrl' => [
'action.optOut' => ts("'Opt out via email' - displays an email address for recipients to opt out of receiving emails from your organization."),
'action.optOutUrl' => ts("'Opt out via web page' - creates a link for recipients to click if they want to opt out of receiving emails from your organization. Alternatively, you can include the 'Opt out via email' token."),
'action.unsubscribe' => ts("'Unsubscribe via email' - displays an email address for recipients to unsubscribe from the specific mailing list used to send this message."),
'action.unsubscribeUrl' => ts("'Unsubscribe via web page' - creates a link for recipients to unsubscribe from the specific mailing list used to send this message. Alternatively, you can include the 'Unsubscribe via email' token or one of the Opt-out tokens."),
- ),
- ),
- )))->setPublic(TRUE);
+ ],
+ ],
+ ]))->setPublic(TRUE);
$container->setDefinition('civi_flexmailer_abdicator', new Definition('Civi\FlexMailer\Listener\Abdicator'))->setPublic(TRUE);
$container->setDefinition('civi_flexmailer_default_batcher', new Definition('Civi\FlexMailer\Listener\DefaultBatcher'))->setPublic(TRUE);
$container->findDefinition('dispatcher')->addMethodCall('addListenerService', $listenerSpec);
}
- $container->findDefinition('civi_api_kernel')->addMethodCall('registerApiProvider', array(new Reference('civi_flexmailer_api_overrides')));
+ $container->findDefinition('civi_api_kernel')->addMethodCall('registerApiProvider', [new Reference('civi_flexmailer_api_overrides')]);
}
/**
* Arguments to pass to addListenerService($eventName, $callbackSvc, $priority).
*/
protected static function getListenerSpecs() {
- $listenerSpecs = array();
+ $listenerSpecs = [];
- $listenerSpecs[] = array(Validator::EVENT_CHECK_SENDABLE, array('civi_flexmailer_abdicator', 'onCheckSendable'), FM::WEIGHT_START);
- $listenerSpecs[] = array(Validator::EVENT_CHECK_SENDABLE, array('civi_flexmailer_required_fields', 'onCheckSendable'), FM::WEIGHT_MAIN);
- $listenerSpecs[] = array(Validator::EVENT_CHECK_SENDABLE, array('civi_flexmailer_required_tokens', 'onCheckSendable'), FM::WEIGHT_MAIN);
+ $listenerSpecs[] = [Validator::EVENT_CHECK_SENDABLE, ['civi_flexmailer_abdicator', 'onCheckSendable'], FM::WEIGHT_START];
+ $listenerSpecs[] = [Validator::EVENT_CHECK_SENDABLE, ['civi_flexmailer_required_fields', 'onCheckSendable'], FM::WEIGHT_MAIN];
+ $listenerSpecs[] = [Validator::EVENT_CHECK_SENDABLE, ['civi_flexmailer_required_tokens', 'onCheckSendable'], FM::WEIGHT_MAIN];
- $listenerSpecs[] = array(FM::EVENT_RUN, array('civi_flexmailer_default_composer', 'onRun'), FM::WEIGHT_MAIN);
- $listenerSpecs[] = array(FM::EVENT_RUN, array('civi_flexmailer_abdicator', 'onRun'), FM::WEIGHT_END);
+ $listenerSpecs[] = [FM::EVENT_RUN, ['civi_flexmailer_default_composer', 'onRun'], FM::WEIGHT_MAIN];
+ $listenerSpecs[] = [FM::EVENT_RUN, ['civi_flexmailer_abdicator', 'onRun'], FM::WEIGHT_END];
- $listenerSpecs[] = array(FM::EVENT_WALK, array('civi_flexmailer_default_batcher', 'onWalk'), FM::WEIGHT_END);
+ $listenerSpecs[] = [FM::EVENT_WALK, ['civi_flexmailer_default_batcher', 'onWalk'], FM::WEIGHT_END];
- $listenerSpecs[] = array(FM::EVENT_COMPOSE, array('civi_flexmailer_basic_headers', 'onCompose'), FM::WEIGHT_PREPARE);
- $listenerSpecs[] = array(FM::EVENT_COMPOSE, array('civi_flexmailer_to_header', 'onCompose'), FM::WEIGHT_PREPARE);
- $listenerSpecs[] = array(FM::EVENT_COMPOSE, array('civi_flexmailer_bounce_tracker', 'onCompose'), FM::WEIGHT_PREPARE);
- $listenerSpecs[] = array(FM::EVENT_COMPOSE, array('civi_flexmailer_default_composer', 'onCompose'), FM::WEIGHT_MAIN - 100);
- $listenerSpecs[] = array(FM::EVENT_COMPOSE, array('civi_flexmailer_attachments', 'onCompose'), FM::WEIGHT_ALTER);
- $listenerSpecs[] = array(FM::EVENT_COMPOSE, array('civi_flexmailer_open_tracker', 'onCompose'), FM::WEIGHT_ALTER);
- $listenerSpecs[] = array(FM::EVENT_COMPOSE, array('civi_flexmailer_test_prefix', 'onCompose'), FM::WEIGHT_ALTER);
- $listenerSpecs[] = array(FM::EVENT_COMPOSE, array('civi_flexmailer_hooks', 'onCompose'), FM::WEIGHT_ALTER - 100);
+ $listenerSpecs[] = [FM::EVENT_COMPOSE, ['civi_flexmailer_basic_headers', 'onCompose'], FM::WEIGHT_PREPARE];
+ $listenerSpecs[] = [FM::EVENT_COMPOSE, ['civi_flexmailer_to_header', 'onCompose'], FM::WEIGHT_PREPARE];
+ $listenerSpecs[] = [FM::EVENT_COMPOSE, ['civi_flexmailer_bounce_tracker', 'onCompose'], FM::WEIGHT_PREPARE];
+ $listenerSpecs[] = [FM::EVENT_COMPOSE, ['civi_flexmailer_default_composer', 'onCompose'], FM::WEIGHT_MAIN - 100];
+ $listenerSpecs[] = [FM::EVENT_COMPOSE, ['civi_flexmailer_attachments', 'onCompose'], FM::WEIGHT_ALTER];
+ $listenerSpecs[] = [FM::EVENT_COMPOSE, ['civi_flexmailer_open_tracker', 'onCompose'], FM::WEIGHT_ALTER];
+ $listenerSpecs[] = [FM::EVENT_COMPOSE, ['civi_flexmailer_test_prefix', 'onCompose'], FM::WEIGHT_ALTER];
+ $listenerSpecs[] = [FM::EVENT_COMPOSE, ['civi_flexmailer_hooks', 'onCompose'], FM::WEIGHT_ALTER - 100];
- $listenerSpecs[] = array(FM::EVENT_SEND, array('civi_flexmailer_default_sender', 'onSend'), FM::WEIGHT_END);
+ $listenerSpecs[] = [FM::EVENT_SEND, ['civi_flexmailer_default_sender', 'onSend'], FM::WEIGHT_END];
return $listenerSpecs;
}
*/
protected static function applyStaticFactory($def, $factoryClass, $factoryMethod) {
if (method_exists($def, 'setFactory')) {
- $def->setFactory(array($factoryClass, $factoryMethod));
+ $def->setFactory([$factoryClass, $factoryMethod]);
}
else {
$def->setFactoryClass($factoryClass)->setFactoryMethod($factoryMethod);
}
$mailing->copyValues($params);
- return (new Validator())->run(array(
+ return (new Validator())->run([
'mailing' => $mailing,
'attachments' => \CRM_Core_BAO_File::getEntityFile('civicrm_mailing', $mailing->id),
- ));
+ ]);
}
/**
// Activate before transactions are setup.
$manager = \CRM_Extension_System::singleton()->getManager();
if ($manager->getStatus('org.civicrm.flexmailer') !== \CRM_Extension_Manager::STATUS_INSTALLED) {
- $manager->install(array('org.civicrm.flexmailer'));
+ $manager->install(['org.civicrm.flexmailer']);
}
parent::setUp();
// Activate before transactions are setup.
$manager = \CRM_Extension_System::singleton()->getManager();
if ($manager->getStatus('org.civicrm.flexmailer') !== \CRM_Extension_Manager::STATUS_INSTALLED) {
- $manager->install(array('org.civicrm.flexmailer'));
+ $manager->install(['org.civicrm.flexmailer']);
}
parent::setUp();
// Activate before transactions are setup.
$manager = \CRM_Extension_System::singleton()->getManager();
if ($manager->getStatus('org.civicrm.flexmailer') !== \CRM_Extension_Manager::STATUS_INSTALLED) {
- $manager->install(array('org.civicrm.flexmailer'));
+ $manager->install(['org.civicrm.flexmailer']);
}
parent::setUp();
// Activate before transactions are setup.
$manager = \CRM_Extension_System::singleton()->getManager();
if ($manager->getStatus('org.civicrm.flexmailer') !== \CRM_Extension_Manager::STATUS_INSTALLED) {
- $manager->install(array('org.civicrm.flexmailer'));
+ $manager->install(['org.civicrm.flexmailer']);
}
parent::setUp();
$dispatcher = \Civi::service('dispatcher');
foreach (FlexMailer::getEventTypes() as $event => $class) {
- $dispatcher->addListener($event, array($this, 'handleEvent'));
+ $dispatcher->addListener($event, [$this, 'handleEvent']);
}
$hooks = \CRM_Utils_Hook::singleton();
$hooks->setHook('civicrm_alterMailParams',
- array($this, 'hook_alterMailParams'));
- $this->counts = array();
+ [$this, 'hook_alterMailParams']);
+ $this->counts = [];
}
public function handleEvent(GenericHookEvent $e) {
// Activate before transactions are setup.
$manager = \CRM_Extension_System::singleton()->getManager();
if ($manager->getStatus('org.civicrm.flexmailer') !== \CRM_Extension_Manager::STATUS_INSTALLED) {
- $manager->install(array('org.civicrm.flexmailer'));
+ $manager->install(['org.civicrm.flexmailer']);
}
parent::setUp();
SimpleFilter::byValue($e, 'text', function ($value, $t, $e) use ($test) {
$test->assertInstanceOf('Civi\FlexMailer\FlexMailerTask', $t);
$test->assertInstanceOf('Civi\FlexMailer\Event\ComposeBatchEvent', $e);
- $test->assertTrue(in_array($value, array(
+ $test->assertTrue(in_array($value, [
'eat more cheese',
'eat more ice cream',
- )));
+ ]));
return preg_replace('/more/', 'thoughtfully considered quantities of', $value);
});
* @return array
*/
protected function createExampleBatch() {
- $tasks = array();
+ $tasks = [];
$tasks[0] = new FlexMailerTask(1000, 2000, 'asdf', 'foo@example.org');
$tasks[1] = new FlexMailerTask(1001, 2001, 'fdsa', 'bar@example.org');
- $e = new ComposeBatchEvent(array(), $tasks);
+ $e = new ComposeBatchEvent([], $tasks);
$tasks[0]->setMailParam('text', 'eat more cheese');
$tasks[1]->setMailParam('text', 'eat more ice cream');
- return array($tasks, $e);
+ return [$tasks, $e];
}
}
// Activate before transactions are setup.
$manager = \CRM_Extension_System::singleton()->getManager();
if ($manager->getStatus('org.civicrm.flexmailer') !== \CRM_Extension_Manager::STATUS_INSTALLED) {
- $manager->install(array('org.civicrm.flexmailer'));
+ $manager->install(['org.civicrm.flexmailer']);
}
parent::setUp();
$this->_contactID = $this->individualCreate();
$this->_groupID = $this->groupCreate();
$this->_email = 'test@test.test';
- $this->_params = array(
+ $this->_params = [
'subject' => 'Hello {contact.display_name}',
'body_text' => "This is {contact.display_name}.\nhttps://civicrm.org\nda=({domain.address}) optout=({action.optOutUrl}) subj=({mailing.subject})",
'body_html' => "<p>This is {contact.display_name}.</p><p><a href='https://civicrm.org/'>CiviCRM.org</a></p><p>da=({domain.address}) optout=({action.optOutUrl}) subj=({mailing.subject})</p>",
'created_id' => $this->_contactID,
'header_id' => '',
'footer_id' => '',
- );
+ ];
- $this->footer = civicrm_api3('MailingComponent', 'create', array(
+ $this->footer = civicrm_api3('MailingComponent', 'create', [
'name' => 'test domain footer',
'component_type' => 'footer',
'body_html' => '<p>From {domain.address}. To opt out, go to {action.optOutUrl}.</p>',
'body_text' => 'From {domain.address}. To opt out, go to {action.optOutUrl}.',
- ));
+ ]);
}
public function tearDown(): void {
// BEGIN SAMPLE DATA
$contactID = $this->individualCreate();
$displayName = $this->callAPISuccess('contact', 'get',
- array('id' => $contactID));
+ ['id' => $contactID]);
$displayName = $displayName['values'][$contactID]['display_name'];
$this->assertTrue(!empty($displayName));
$params = $this->_params;
- $params['api.Mailing.preview'] = array(
+ $params['api.Mailing.preview'] = [
'id' => '$value.id',
'contact_id' => $contactID,
- );
+ ];
$params['options']['force_rollback'] = 1;
// END SAMPLE DATA
* Array(string $table => int $maxID).
*/
protected function getMaxIds() {
- return array(
+ return [
'civicrm_mailing' => \CRM_Core_DAO::singleValueQuery('SELECT MAX(id) FROM civicrm_mailing'),
'civicrm_mailing_job' => \CRM_Core_DAO::singleValueQuery('SELECT MAX(id) FROM civicrm_mailing_job'),
'civicrm_mailing_group' => \CRM_Core_DAO::singleValueQuery('SELECT MAX(id) FROM civicrm_mailing_group'),
'civicrm_mailing_recipients' => \CRM_Core_DAO::singleValueQuery('SELECT MAX(id) FROM civicrm_mailing_recipients'),
- );
+ ];
}
/**
// Activate before transactions are setup.
$manager = \CRM_Extension_System::singleton()->getManager();
if ($manager->getStatus('org.civicrm.flexmailer') !== \CRM_Extension_Manager::STATUS_INSTALLED) {
- $manager->install(array('org.civicrm.flexmailer'));
+ $manager->install(['org.civicrm.flexmailer']);
}
parent::setUp();
}
public function getExamples() {
- $defaults = array(
+ $defaults = [
'id' => 123,
'subject' => 'Default subject',
'name' => 'Default name',
'body_html' => '<html>Default HTML body {action.unsubscribeUrl} {domain.address}</html>',
'body_text' => 'Default text body {action.unsubscribeUrl} {domain.address}',
'template_type' => 'traditional',
- 'template_options' => array(),
- );
+ 'template_options' => [],
+ ];
- $es = array();
- $es[] = array(
- array_merge($defaults, array('subject' => NULL)),
- array('subject' => '/Field "subject" is required./'),
- );
- $es[] = array(
- array_merge($defaults, array('subject' => NULL, 'from_name' => NULL)),
- array(
+ $es = [];
+ $es[] = [
+ array_merge($defaults, ['subject' => NULL]),
+ ['subject' => '/Field "subject" is required./'],
+ ];
+ $es[] = [
+ array_merge($defaults, ['subject' => NULL, 'from_name' => NULL]),
+ [
'subject' => '/Field "subject" is required./',
'from_name' => '/Field "from_name" is required./',
- ),
- );
- $es[] = array(
- array_merge($defaults, array('body_text' => NULL)),
- array(),
- );
- $es[] = array(
- array_merge($defaults, array('body_html' => NULL)),
- array(),
- );
- $es[] = array(
- array_merge($defaults, array('body_html' => NULL, 'body_text' => NULL)),
- array('(body_html|body_text)' => '/Field "body_html" or "body_text" is required./'),
- );
- $es[] = array(
- array_merge($defaults, array('body_html' => 'Muahaha. I omit the mandatory tokens!')),
- array(
+ ],
+ ];
+ $es[] = [
+ array_merge($defaults, ['body_text' => NULL]),
+ [],
+ ];
+ $es[] = [
+ array_merge($defaults, ['body_html' => NULL]),
+ [],
+ ];
+ $es[] = [
+ array_merge($defaults, ['body_html' => NULL, 'body_text' => NULL]),
+ ['(body_html|body_text)' => '/Field "body_html" or "body_text" is required./'],
+ ];
+ $es[] = [
+ array_merge($defaults, ['body_html' => 'Muahaha. I omit the mandatory tokens!']),
+ [
'body_html:domain.address' => '/This message is missing.*postal address/',
'body_html:action.optOutUrl or action.unsubscribeUrl' => '/This message is missing.*Unsubscribe via web page/',
- ),
- );
- $es[] = array(
- array_merge($defaults, array('body_html' => 'I omit the mandatory tokens, but checking them is someone else\'s job!', 'template_type' => 'esperanto')),
- array(),
- );
+ ],
+ ];
+ $es[] = [
+ array_merge($defaults, ['body_html' => 'I omit the mandatory tokens, but checking them is someone else\'s job!', 'template_type' => 'esperanto']),
+ [],
+ ];
return $es;
}
*/
function cv($cmd, $decode = 'json') {
$cmd = 'cv ' . $cmd;
- $descriptorSpec = array(0 => array("pipe", "r"), 1 => array("pipe", "w"), 2 => STDERR);
+ $descriptorSpec = [0 => ["pipe", "r"], 1 => ["pipe", "w"], 2 => STDERR];
$oldOutput = getenv('CV_OUTPUT');
putenv("CV_OUTPUT=json");
$process = proc_open($cmd, $descriptorSpec, $pipes, __DIR__);
/** @var \Civi\Angular\AngularLoader $loader */
$loader = \Civi::service('angularjs.loader');
$loader->addModules(['crmMsgadm']);
- $loader->useApp(array(
+ $loader->useApp([
'defaultRoute' => '/user',
- ));
+ ]);
parent::run();
}
*/
function cv($cmd, $decode = 'json') {
$cmd = 'cv ' . $cmd;
- $descriptorSpec = array(0 => array("pipe", "r"), 1 => array("pipe", "w"), 2 => STDERR);
+ $descriptorSpec = [0 => ["pipe", "r"], 1 => ["pipe", "w"], 2 => STDERR];
$oldOutput = getenv('CV_OUTPUT');
putenv("CV_OUTPUT=json");
*/
function cv($cmd, $decode = 'json') {
$cmd = 'cv ' . $cmd;
- $descriptorSpec = array(0 => array("pipe", "r"), 1 => array("pipe", "w"), 2 => STDERR);
+ $descriptorSpec = [0 => ["pipe", "r"], 1 => ["pipe", "w"], 2 => STDERR];
$oldOutput = getenv('CV_OUTPUT');
putenv("CV_OUTPUT=json");
*/
function cv($cmd, $decode = 'json') {
$cmd = 'cv ' . $cmd;
- $descriptorSpec = array(0 => array("pipe", "r"), 1 => array("pipe", "w"), 2 => STDERR);
+ $descriptorSpec = [0 => ["pipe", "r"], 1 => ["pipe", "w"], 2 => STDERR];
$oldOutput = getenv('CV_OUTPUT');
putenv("CV_OUTPUT=json");