本文整理汇总了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();
}