本文整理匯總了PHP中X2Model::beforeSave方法的典型用法代碼示例。如果您正苦於以下問題:PHP X2Model::beforeSave方法的具體用法?PHP X2Model::beforeSave怎麽用?PHP X2Model::beforeSave使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類X2Model
的用法示例。
在下文中一共展示了X2Model::beforeSave方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: beforeSave
/**
* Formats data for associatedContacts before saving
* @return boolean whether or not to save
*/
public function beforeSave()
{
if (isset($this->associatedContacts)) {
$this->associatedContacts = self::parseContacts($this->associatedContacts);
}
return parent::beforeSave();
}
示例2: beforeSave
/**
* Fixes up record association, parses dates (since this doesn't use
* {@link X2Model::setX2Fields()})
* @return boolean whether or not to save
*/
public function beforeSave()
{
if ($this->scenario !== 'workflow') {
$association = self::getAssociationModel($this->associationType, $this->associationId);
if ($association === null) {
$this->associationName = 'None';
$this->associationId = 0;
} else {
if ($association->hasAttribute('name')) {
$this->associationName = $association->name;
}
if ($association->asa('X2TimestampBehavior') !== null) {
if ($association->asa('changelog') !== null && Yii::app()->getSuName() == 'Guest') {
$association->disableBehavior('changelog');
}
$association->updateLastActivity();
$association->enableBehavior('changelog');
}
}
if ($this->associationName == 'None' && $this->associationType != 'none') {
$this->associationName = ucfirst($this->associationType);
}
$this->dueDate = Formatter::parseDateTime($this->dueDate);
$this->completeDate = Formatter::parseDateTime($this->completeDate);
}
// Whether this is a "timed" action record:
$timed = $this->isTimedType;
if (empty($timeSpent) && !empty($this->completeDate) && !empty($this->dueDate) && $timed) {
$this->timeSpent = $this->completeDate - $this->dueDate;
}
return parent::beforeSave();
}
示例3: beforeSave
public function beforeSave()
{
if (empty($this->associationType)) {
$this->associationType = 'none';
}
if (empty($this->uploadedBy)) {
$this->uploadedBy = Yii::app()->user->name;
}
if (empty($this->name)) {
$this->name = $this->fileName;
}
if ($this->isNewRecord && $this->associationType !== 'theme' && empty($this->accessKey)) {
$this->accessKey = bin2hex(openssl_random_pseudo_bytes(32));
}
$this->getPath();
return parent::beforeSave();
}
示例4: beforeSave
public function beforeSave()
{
// backwards compatibility check for when leads didn't have first and last name fields
if (!$this->isNewRecord && !$this->firstName && !$this->lastName && ($this->attributeChanged('firstName') || $this->attributeChanged('lastName'))) {
$this->name = '';
}
return parent::beforeSave();
}
示例5: beforeSave
/**
* @return boolean whether or not to save
*/
public function beforeSave()
{
if ($this->trackingKey === null) {
$this->trackingKey = self::getNewTrackingKey();
}
return parent::beforeSave();
}