本文整理汇总了PHP中Campaign::getByStatus方法的典型用法代码示例。如果您正苦于以下问题:PHP Campaign::getByStatus方法的具体用法?PHP Campaign::getByStatus怎么用?PHP Campaign::getByStatus使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Campaign
的用法示例。
在下文中一共展示了Campaign::getByStatus方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: markProcessedCampaignsAsCompleted
/**
* @param null $pageSize | int $pageSize
* @return bool
*/
public static function markProcessedCampaignsAsCompleted($pageSize = null)
{
if ($pageSize != null) {
$resolvedPageSize = $pageSize + 1;
} else {
$resolvedPageSize = $pageSize;
}
$processingCampaigns = Campaign::getByStatus(Campaign::STATUS_PROCESSING, $resolvedPageSize);
$campaignsProcessed = 0;
foreach ($processingCampaigns as $processingCampaign) {
if ($campaignsProcessed < $pageSize || $pageSize == null) {
if (static::areAllCampaignItemsProcessed($processingCampaign->id)) {
$processingCampaign->status = Campaign::STATUS_COMPLETED;
if (!$processingCampaign->save()) {
return false;
}
}
$campaignsProcessed++;
} else {
Yii::app()->jobQueue->add('CampaignMarkCompleted', 5);
break;
}
}
return true;
}
示例2: markProcessedCampaignsAsCompleted
/**
* @param null $pageSize | int $pageSize
* @return bool
*/
public static function markProcessedCampaignsAsCompleted($pageSize = null)
{
$processingCampaigns = Campaign::getByStatus(Campaign::STATUS_PROCESSING, $pageSize);
foreach ($processingCampaigns as $processingCampaign) {
if (static::areAllCampaignItemsProcessed($processingCampaign->id)) {
$processingCampaign->status = Campaign::STATUS_COMPLETED;
if (!$processingCampaign->save()) {
return false;
}
}
}
return true;
}
示例3: testGetByStatus
/**
* @depends testCreateAndGetCampaignListById
*/
public function testGetByStatus()
{
$totalCampaigns = Campaign::getAll();
$this->assertNotEmpty($totalCampaigns);
$this->assertCount(4, $totalCampaigns);
$dueActiveCampaigns = Campaign::getByStatus(Campaign::STATUS_ACTIVE);
$this->assertNotEmpty($dueActiveCampaigns);
$this->assertCount(3, $dueActiveCampaigns);
$campaign = $dueActiveCampaigns[0];
$this->assertEquals('Test Campaign Name2', $campaign->name);
$this->assertEquals(0, $campaign->supportsRichText);
$this->assertEquals('From Name2', $campaign->fromName);
$this->assertEquals('from2@zurmo.com', $campaign->fromAddress);
$this->assertEquals('Test Subject2', $campaign->subject);
$this->assertEquals('Test Html Content2', $campaign->htmlContent);
$this->assertEquals('Test Text Content2', $campaign->textContent);
$duePausedCampaigns = Campaign::getByStatus(Campaign::STATUS_PAUSED);
$this->assertNotEmpty($duePausedCampaigns);
$this->assertCount(1, $duePausedCampaigns);
$campaign = $duePausedCampaigns[0];
$this->assertEquals('Test Campaign Name', $campaign->name);
$this->assertEquals(1, $campaign->supportsRichText);
$this->assertEquals(Campaign::STATUS_PAUSED, $campaign->status);
$this->assertEquals('From Name', $campaign->fromName);
$this->assertEquals('from@zurmo.com', $campaign->fromAddress);
$this->assertEquals('Test Subject', $campaign->subject);
$this->assertEquals('Test Html Content', $campaign->htmlContent);
$this->assertEquals('Test Text Content', $campaign->textContent);
}