public function afterFind($event) { if ($this->getAttribute() !== NULL) { $this->_value = $this->getOwner()->getAttribute($this->getAttribute()); } return parent::afterFind($event); }
public function afterFind($event) { parent::afterFind($event); //это не открывать, работает для всех взаимосвязанных элементов // if(!Common::isCLI() && ($history = request()->getParam('history')) ){ // $this->getFullHistory($history); // } }
/** * Decripts the values of specified attributes after finding from database * @param CEvent $event * @return parent::afterFind */ public function afterFind($event) { foreach ($this->getOwner()->getAttributes() as $key => $value) { if (in_array($key, $this->attributes) && !empty($value)) { if ($this->useAESMySql) { $this->getOwner()->{$key} = $this->mysqlAESDecrypt($value, Yii::app()->securityManager->getEncryptionKey()); } else { $this->getOwner()->{$key} = Yii::app()->securityManager->decrypt(utf8_decode($value)); } } } return parent::afterFind($event); }
public function afterFind($event) { $owner = $this->getOwner(); foreach ($this->attributes as $attr) { if (isset($owner->{$attr})) { $date = new DateTime($owner->{$attr}); $date->setTimezone(new DateTimeZone(Yii::app()->controller->timezone)); $owner->setAttribute($attr, $date->format('Y-m-d H:i:s')); } else { //throw exception } } parent::afterFind($event); }
/** * Converts ISO 9075 dates to $dateFormat after read from database */ public function afterFind($event) { foreach ($this->dateColumns as $date) { $_dt = $this->Owner->{$date}; if (preg_match("/([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})/", $_dt, $regs)) { $_dt = $regs[3] . "/" . $regs[2] . "/" . $regs[1]; } if ($_dt == '00/00/0000') { $this->Owner->{$date} = ''; } else { $this->Owner->{$date} = $_dt; } } return parent::afterFind($event); }
public function afterFind($event) { foreach ($this->attributes as $attribute => $format) { if (!$this->owner->hasAttribute($attribute)) { continue; } $format = $format == null ? self::FORMAT_DEFAULT : $format; if ($this->owner->getAttribute($attribute) == '0') { $this->attributes[$attribute] = $this->emptyMark; } else { $this->attributes[$attribute] = Yii::app()->dateFormatter->format($format, $this->owner->getAttribute($attribute)); } } $this->owner->setAttributes($this->attributes); parent::afterFind($event); }
/** * Provides creating related HAS_ONE records in memory. * * @param CEvent $event event object * * @see CActiveRecordBehavior::afterFind() * * @throws Exception */ public function afterFind($event) { $owner = $this->getOwner(); foreach ($owner->relations() as $key => $relation) { $isHasOne = $relation['0'] == CActiveRecord::HAS_ONE; if (!$isHasOne) { continue; } if (isset($this->relations[$key]) || in_array($key, $this->relations)) { $config = $this->_getRelationConfig($key); if ($config['createRelated']) { $criteria = new CDbCriteria(); $parameters = array_slice($relation, self::RELATION_REQUIRED_PARAMS_COUNT); foreach ($parameters as $name => $value) { $name = $name == 'on' ? 'condition' : $name; $criteria->{$name} = $value; } $criteria->compare($relation[2], $owner->primaryKey); $model = CActiveRecord::model($relation[1]); if (!$model->exists($criteria)) { $related = new $relation[1](); $related->{$relation}[2] = $owner->primaryKey; if ($config['insertIfNotExists']) { if (!$related->save(false)) { $message = 'Can not save related record. ' . CHtml::errorSummary($related); throw new CException($message); } } $this->owner->addRelatedRecord($key, $related, false); } } } } parent::afterFind($event); }
public function afterFind($event) { if ($this->owner->findMode === TActiveRecord::FIND_ONE) { foreach ($this->config as $item) { $prefix = $item['prefix']; $type = $item['type']; $privArray = $this->getPriv($type); foreach ($privArray as $scope => $value) { $this->owner->{$prefix . $scope} = $value; } } } parent::afterFind($event); }
public function afterFind($event) { // Save old values $this->setOldAttributes($this->Owner->getAttributes()); return parent::afterFind($event); }
/** * Actions to be performed after the model is loaded */ public function afterFind($event) { $this->_dbAttributes = $this->owner->getAttributes(); parent::afterFind($event); }
/** * Load status after find model. * @param CEvent */ public function afterFind($event) { $this->_status = $this->getOwner()->getAttribute($this->statusField); $this->_statusText = isset($this->statuses[$this->_status]) ? $this->statuses[$this->_status] : 'unknown'; parent::afterFind($event); }
public function afterFind($event) { $this->setOldAttributes($this->getOwner()->getAttributes()); return parent::afterFind($event); }
/** * Apply object translation */ public function afterFind($event) { if (!$this->disableEvents) { $this->applyTranslation(); } return parent::afterFind($event); }
/** * Apply object translation */ public function afterFind($event) { $this->_oldTags = $this->getOwner()->tags; return parent::afterFind($event); }
/** * @param CEvent $event */ public function afterFind($event) { $this->_convertAttributesFromDB(); parent::afterFind($event); }
public function afterFind($event) { parent::afterFind($event); $this->processAttributes($event->sender, self::DIRECTION_CLIENT); }
/** * @param CEvent * @return void */ public function afterFind($event) { // Load attributes for model. if ($this->preload) { if ($this->owner->getPrimaryKey()) { // Added by firstrow@gmail.com $this->loadEavAttributes($this->getSafeAttributesArray()); } } // Call parent method for convenience. parent::afterFind($event); }
/** * @param CEvent * @return void */ public function afterFind($event) { // Load attributes for model. if ($this->preload) { $this->loadEavAttributes($this->getSafeAttributesArray()); } // Call parent method for convenience. parent::afterFind($event); }
public function afterFind($event) { parent::afterFind($event); $cacheKey = 'Video::' . $this->owner->youtubeId; $data = Yii::app()->cache->get($cacheKey); if ($data === false || !$data['length']) { //empty length means "video not processed yet" list($utub, $video) = $this->getVideo(); $data = array('flashPlayerUrl' => $video->getFlashPlayerUrl(), 'description' => $video->getVideoDescription(), 'length' => $video->getVideoDuration(), 'thumbnails' => $video->getVideoThumbnails(), 'title' => $video->getVideoTitle(), 'viewCount' => (int) $video->getVideoViewCount()); Yii::app()->cache->set('Video::' . $this->owner->youtubeId, $data); } foreach ($data as $attr => $value) { $this->{$attr} = $value; } }
/** * Converts UNIX timestamp dates to $dateFormat after read from database */ public function afterFind($event) { $this->format($this->dateColumns, $this->dateFormat, false); $this->format($this->dateTimeColumns, $this->dateTimeFormat, false); return parent::afterFind($event); }