本文整理汇总了PHP中BaseElementModel::getStatus方法的典型用法代码示例。如果您正苦于以下问题:PHP BaseElementModel::getStatus方法的具体用法?PHP BaseElementModel::getStatus怎么用?PHP BaseElementModel::getStatus使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BaseElementModel
的用法示例。
在下文中一共展示了BaseElementModel::getStatus方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getStatus
/**
* @inheritDoc BaseElementModel::getStatus()
*
* @return string|null
*/
public function getStatus()
{
$status = parent::getStatus();
if ($status == static::ENABLED && $this->postDate) {
$currentTime = DateTimeHelper::currentTimeStamp();
$postDate = $this->postDate->getTimestamp();
$expiryDate = $this->expiryDate ? $this->expiryDate->getTimestamp() : null;
if ($postDate <= $currentTime && (!$expiryDate || $expiryDate > $currentTime)) {
return static::LIVE;
} else {
if ($postDate > $currentTime) {
return static::PENDING;
} else {
return static::EXPIRED;
}
}
}
return $status;
}
示例2: routeRequestForMatchedElement
/**
* Routes the request when the URI matches an element.
*
* @param BaseElementModel $element
*
* @return array|bool|mixed
*/
public function routeRequestForMatchedElement(BaseElementModel $element)
{
// Make sure that the entry is actually live
if ($element->getStatus() == EntryModel::LIVE) {
$section = $element->getSection();
// Make sure the section is set to have URLs and is enabled for this locale
if ($section->hasUrls && array_key_exists(craft()->language, $section->getLocales())) {
return array('action' => 'templates/render', 'params' => array('template' => $section->template, 'variables' => array('entry' => $element)));
}
}
return false;
}
示例3: getStatus
/**
* Pending - has all required attributes and is disabled or
* does not have all required attributes
* Ready - has all required attributes, and is enabled
* Archived - has been sent, or exported and manually marked archived
*/
public function getStatus()
{
$status = parent::getStatus();
// Required attributes :$campaign->mailer && $campaign->template
// Enabled : static::ENABLED
// Disabled : static::DISABLED
// Archived : static::ARCHIVED
// Sent (track sent dates in a sent log table)
//
// @todo We can make this conditional statement more
// advanced and check for the Service Provider and determine
// specific things about each service provider to decide if an
// email is ready or not. For now, we'll just check to see if
// it has a service provider and text template.
$campaign = sproutEmail()->campaigns->getCampaignById($this->campaignId);
switch ($status) {
case BaseElementModel::DISABLED:
return static::DISABLED;
break;
case BaseElementModel::ENABLED:
if ($this->sent) {
return static::ARCHIVED;
}
if (empty($campaign->template) or empty($campaign->mailer)) {
return static::PENDING;
}
return static::READY;
break;
case BaseElementModel::ARCHIVED:
return static::ARCHIVED;
break;
}
}
示例4: routeRequestForMatchedElement
/**
* Routes the request when the URI matches a product.
*
* @param BaseElementModel $element
*
* @return array|bool|mixed
*/
public function routeRequestForMatchedElement(BaseElementModel $element)
{
/** @var Market_ProductModel $element */
if ($element->getStatus() == Market_ProductModel::LIVE) {
$productType = $element->type;
if ($productType->hasUrls) {
return ['action' => 'templates/render', 'params' => ['template' => $productType->template, 'variables' => ['product' => $element]]];
}
}
return false;
}
示例5: getStatus
/**
* Returns the entry status based on actual values and dynamic checking
*
* Disabled - Entry is disabled
* Archived - Entry has been manually set to archived
* Pending - Entry is enabled but some requirements are not yet met
* Ready - Entry is enabled and all requirements are met
*
* @return string
*/
public function getStatus()
{
$status = parent::getStatus();
$campaign = sproutEmail()->campaigns->getCampaignById($this->campaignId);
switch ($status) {
case BaseElementModel::DISABLED:
return static::DISABLED;
break;
case BaseElementModel::ENABLED:
if ($this->sent) {
return static::ARCHIVED;
}
if (empty($campaign->mailer) || empty($campaign->template)) {
return static::PENDING;
}
return static::READY;
break;
case BaseElementModel::ARCHIVED:
return static::ARCHIVED;
break;
}
}