Example #1
0
 function __get($name)
 {
     if ($name == 'description') {
         return $this->description();
     }
     return parent::__get($name);
 }
 public function __get($name)
 {
     if (array_key_exists($name, $this->_langAttributes)) {
         return $this->_langAttributes[$name];
     } else {
         return parent::__get($name);
     }
 }
Example #3
0
 public function __get($name)
 {
     if (isset($this->_fieldsArias[$name])) {
         return parent::__get($this->_fieldsArias[$name]);
     } else {
         return parent::__get($name);
     }
 }
Example #4
0
 public function __get($name)
 {
     if ($name == $this->getAttribute('id_attr')) {
         return $this->value;
     } else {
         return parent::__get($name);
     }
 }
Example #5
0
 public function __get($name)
 {
     if ($name == 'survey') {
         $relationModelClassName = $this->surveyLocation;
         return $relationModelClassName::model()->findByPk($this->surveyId);
     }
     return parent::__get($name);
 }
Example #6
0
 public function __get($name)
 {
     $getter = 'get' . $name;
     if (method_exists($this, $getter)) {
         return $this->{$getter}();
     }
     return parent::__get($name);
 }
Example #7
0
 /**
  * 复杂类型字段读取实现
  */
 public function __get($name)
 {
     if (in_array($name, $this->complexAttributes())) {
         $value = parent::__get($name);
         return CJSON::decode($value);
     } else {
         return parent::__get($name);
     }
 }
 public function __get($name)
 {
     $upper = strtoupper($name);
     if ($this->hasAttribute($upper) || $this->hasRelated($upper)) {
         return parent::__get($upper);
     } else {
         return parent::__get($name);
     }
 }
Example #9
0
 public function __get($name)
 {
     try {
         return parent::__get($name);
     } catch (\Exception $ex) {
         $e = $ex;
     }
     if (array_key_exists($name, $this->dataStore)) {
         return $this->dataStore[$name];
     }
     throw $e;
 }
 public function __get($name)
 {
     try {
         return parent::__get($name);
     } catch (Exception $e) {
         $error = $e->getMessage();
         $msg = 'Failed to retrieve a required property ("' . $name . '"): ' . $error . '<br/>This can be due to an outdated database.<br/>';
         if (!Yii::app()->controller instanceof InstallController) {
             $msg .= '<br/>Please run the ' . CHtml::link('control panel installer', Yii::app()->request->getBaseUrl(true) . '/install.php') . ' to fix this issue.<br/>';
         }
         throw new RawHttpException(500, $msg);
     }
 }
Example #11
0
 public function __get($name)
 {
     try {
         return parent::__get($name);
     } catch (CException $e) {
         $method_name = StringHelper::underscoreToCamelcase($name);
         $method_name = 'get' . ucfirst($method_name);
         if (method_exists($this, $method_name)) {
             return $this->{$method_name}();
         } else {
             throw new CException($e->getMessage());
         }
     }
 }
Example #12
0
 public function __get($name)
 {
     $lang = Yii::app()->getLanguage();
     $att = $name . '_' . $lang;
     if ($this->hasAttribute($att)) {
         $value = parent::__get($att);
         if (!$value) {
             $defaultLang = Yii::app()->params['defaultLanguage'];
             return parent::__get($name . '_' . $defaultLang);
         } else {
             return $value;
         }
     }
     return parent::__get($name);
 }
 public function __get($name)
 {
     if (!$this->eavEnable) {
         return parent::__get($name);
     }
     try {
         return parent::__get($name);
     } catch (CException $ex) {
         if ($this->hasEavAttribute($name)) {
             return $this->getEavAttribute($name);
         } else {
             throw $ex;
         }
     }
 }
Example #14
0
 public function __get($name)
 {
     try {
         return parent::__get($name);
     } catch (CException $e) {
         if (substr($name, -6) == '_label') {
             $attribute = substr($name, 0, -6);
             return $this->getAttributeLabel($attribute);
         }
         $method_name = Yii::app()->text->underscoreToCamelcase($name);
         $method_name = 'get' . ucfirst($method_name);
         if (method_exists($this, $method_name)) {
             return $this->{$method_name}();
         } else {
             throw new CException($e->getMessage());
         }
     }
 }
 public function __get($name)
 {
     try {
         return parent::__get($name);
     } catch (CException $e) {
         $method_name = StringHelper::underscoreToCamelcase($name);
         if (method_exists($this, 'get' . ucfirst($method_name))) {
             return $this->{$method_name};
         } else {
             $attr = StringHelper::camelCaseToUnderscore($name);
             if (mb_substr($attr, 0, 4) == 'get_') {
                 $attr = mb_substr($attr, 4);
             }
             $attr = get_class($this) . '.' . $attr;
             throw new CException('Не определено свойство ' . $attr);
         }
     }
 }
Example #16
0
 public function __get($name)
 {
     // Override stores relation to include default store
     if ($name == 'stores') {
         if (CategoryToStore::model()->exists("category_id={$this->category_id} AND store_id=0")) {
             $stores = parent::__get($name);
             $default = new Store();
             $default->name = Yii::t('stores', 'Default');
             $default->store_id = 0;
             $default->ssl = Yii::app()->baseUrl;
             // TODO: what should i do about ssl?!
             $default->url = Yii::app()->baseUrl;
             array_unshift($stores, $default);
             return $stores;
         }
     } else {
         return parent::__get($name);
     }
 }
Example #17
0
 public function __get($name)
 {
     if ($this->isSerializedAttr($name)) {
         return $this->getData()->{$name};
     } else {
         return parent::__get($name);
     }
 }
 public function __get($name)
 {
     $flags = $this->cachedFlags();
     if (strncasecmp($name, $this->namePrefix, 2) === 0) {
         $flagName = substr(strtolower($name), strlen($this->namePrefix));
         if (isset($flags[$flagName])) {
             return $this->getFlag($flags[$flagName]);
         }
     }
     return parent::__get($name);
 }
Example #19
0
 public function __get($name)
 {
     if (strpos($name, '.') !== false) {
         $parts = explode('.', $name);
         return isset($this->Search[$parts[0]][$parts[1]]) ? $this->Search[$parts[0]][$parts[1]] : '';
     } else {
         return parent::__get($name);
     }
 }
Example #20
0
 public function __get($name)
 {
     switch (true) {
         case Helper::isLastString($name, 'Count'):
             $name = substr_replace($name, '', -5);
             $this->initRelation();
             if (isset($this->__relations[$name])) {
                 $rel = $this->__relations[$name];
                 if (count($rel) == 0) {
                     return 0;
                 } else {
                     if (Helper::is_assoc($rel)) {
                         return 1;
                     } else {
                         if ($name == 'currentModel') {
                             $tableSchema = $this->tableSchema;
                             $builder = $this->commandBuilder;
                             $countCommand = $builder->createCountCommand($tableSchema, new CDbCriteria());
                             return $countCommand->queryScalar();
                         } else {
                             $c = $this->getRelated($name, true, ['select' => 'count(1) as id']);
                             return $c[0]->id;
                         }
                     }
                 }
             }
             break;
         case Helper::isLastString($name, 'PageSize'):
             $name = substr_replace($name, '', -8);
             if (isset($this->__pageSize[$name])) {
                 return $this->__pageSize[$name];
             } else {
                 return ActiveRecord::DEFAULT_PAGE_SIZE;
             }
             break;
         case Helper::isLastString($name, 'CurrentPage'):
             $name = substr_replace($name, '', -11);
             return @$this->__page[$name] ? $this->__page[$name] : 1;
             break;
         case Helper::isLastString($name, 'Insert'):
             $name = substr_replace($name, '', -6);
             return @$this->__relInsert[$name];
             break;
         case Helper::isLastString($name, 'Update'):
             $name = substr_replace($name, '', -6);
             return @$this->__relUpdate[$name];
             break;
         case Helper::isLastString($name, 'Delete'):
             $name = substr_replace($name, '', -6);
             return @$this->__relDelete[$name];
             break;
         case $name == 'currentModel':
             return $this->loadRelation($name);
             break;
         case isset($this->__relations[$name]):
             if (empty($this->__relations[$name])) {
                 $this->loadRelation($name);
             }
             return $this->__relations[$name];
             break;
         case isset($this->__tempVar[$name]):
             return $this->__tempVar;
             break;
         default:
             return parent::__get($name);
             break;
     }
 }
Example #21
0
 public function __get($name)
 {
     if ($name == 'price') {
         return round($this->getAttribute($name), 2);
     }
     return parent::__get($name);
 }