Esempio n. 1
0
 /**
  * @inheritDoc
  */
 protected function _getValue(ActiveRecord $model)
 {
     if ($model instanceof ActiveRecord) {
         /** @var ActiveRecord $model */
         return $model->__get($this->attributeName);
     }
 }
Esempio n. 2
0
 public function __get($name)
 {
     if (isset($this->_pivotAttributes[$name])) {
         return $this->_pivotAttributes[$name];
     }
     return parent::__get($name);
 }
Esempio n. 3
0
 public function __get($name)
 {
     if ($name === 'history') {
         return $this->getHistory();
     }
     return parent::__get($name);
 }
Esempio n. 4
0
 public function __get($name)
 {
     if ($name == 'display_type') {
         return $this->getDisplayType();
     } else {
         return parent::__get($name);
     }
 }
Esempio n. 5
0
 public function __get($name)
 {
     if (in_array($name, $this->jsonParams)) {
         return $this->getJsonParams($name);
     } else {
         return parent::__get($name);
     }
 }
 /**
  * Override __get of yii\db\ActiveRecord
  *
  * @param string $name the property name
  * @return mixed
  */
 public function __get($name)
 {
     if ($this->hasAttribute($name)) {
         return parent::__get($name);
     } else {
         return $this->getMetaAttribute($name);
     }
 }
Esempio n. 7
0
 /**
  * @param string $field
  *
  * @return mixed|void
  */
 public function __get($field)
 {
     if (in_array($field, $this->getMultiLangFields())) {
         $language = \Yii::$app->language;
         $field = $this->buildMultilangFieldName($field, $language);
     }
     return parent::__get($field);
 }
Esempio n. 8
0
 public function __get($name)
 {
     if (!in_array($name, $this->attributes()) && !empty($this->app->elements[$name]) && ($behavior = $this->getBehavior($this->app->elements[$name]->type)) !== null) {
         return $behavior->getValue($name);
     } else {
         return parent::__get($name);
     }
 }
Esempio n. 9
0
 /**
  * @inheritdoc
  */
 public function __get($name)
 {
     if ($this->_schema && isset($this->_schema[$name])) {
         if (array_key_exists($name, $this->_values)) {
             return $this->_values[$name];
         } else {
             return null;
         }
     }
     return parent::__get($name);
 }
Esempio n. 10
0
 public function __get($name)
 {
     try {
         return parent::__get($name);
     } catch (UnknownPropertyException $e) {
         if (isset($this->_transformers[$name])) {
             return $this->_transformers[$name]->transformFrom();
         }
         return parent::__get(static::prop2col($name));
     }
 }
Esempio n. 11
0
 public function __get($name)
 {
     if (in_array($name, $this->getDefaultFields())) {
         return parent::__get($name);
     }
     if (in_array($name, $this->getSkipFields())) {
         $rules = Json::decode($this->rules);
         if (isset($rules[$name])) {
             return $rules[$name];
         }
     }
     return [];
 }
Esempio n. 12
0
 /**
  * @return mixed
  */
 public function __get($name)
 {
     // if the attribute is defined as a meta-attribute, fetch it
     // otherwise let the parent class handle the request
     if ($this->hasMetaAttribute($name)) {
         return $this->getMeta($name);
     } else {
         if (($val = ArrayHelper::getValue($this, $name)) !== null) {
             return $val;
         } else {
             return parent::__get($name);
         }
     }
 }
 /**
  * Returns if a model attribute is set.
  *
  * @param string $name attribute name, use dotted notation for structured attributes.
  *
  * @return bool true if the attribute is set
  */
 public function issetAttribute($name)
 {
     try {
         if (parent::__get($name) !== null) {
             return true;
         }
     } catch (Exception $ignore) {
     }
     $path = explode('.', $name);
     $ref =& $this->_dynamicAttributes;
     foreach ($path as $key) {
         if (!isset($ref[$key])) {
             return false;
         }
         $ref =& $ref[$key];
     }
     return true;
 }
Esempio n. 14
0
 public function __get($key)
 {
     if ($key = $this->hasKey($key)) {
         return parent::__get($key);
     }
 }
 /**
  * @inheritdoc
  */
 public function __get($name)
 {
     return $name === 'name' ? $this->name() : parent::__get($name);
 }
 public function __get($name)
 {
     // lazy loading LINK and LINKLIST
     if (is_a($this->getAttribute($name), 'PhpOrient\\Protocols\\Binary\\Data\\ID') || $this->isArrayOfRid($this->getAttribute($name))) {
         if ($relation = $this->getRelation($name, false)) {
             if (!$relation->embedded) {
                 if ($relation->multiple) {
                     $rids = $this->getAttribute($name);
                     $ridsResult = [];
                     foreach ($rids as $rid) {
                         array_push($ridsResult, DataRreaderOrientDB::IDtoRid($rid));
                     }
                     $relation->andWhere(['in', '@rid', $ridsResult]);
                     // load relation data:
                     $this->{$name} = $relation->all();
                     $this->populateRelation($name, $this);
                     //                        return $this->$name;
                 } else {
                     $rid = $this->getAttribute($name);
                     $relation->andWhere(['=', '@rid', DataRreaderOrientDB::IDtoRid($rid)]);
                     // load relation data:
                     $this->{$name} = $relation->one();
                     $this->populateRelation($name, $this);
                     //                        return $this->$name;
                 }
             }
         }
     }
     return parent::__get($name);
 }
 public function __get($name)
 {
     if (isset($this->_extraFields[$name]) || array_key_exists($name, $this->_extraFields)) {
         return $this->_extraFields[$name];
     } else {
         return parent::__get($name);
     }
 }
Esempio n. 18
0
 public function __get($attribute)
 {
     if (!isset($this->__attributes) && isset($this->id)) {
         $atts = $this->allCategoryAttributes;
         if (is_array($atts)) {
             foreach ($atts as $att) {
                 $this->__attributes[$att->code] = CatalogValues::find()->where(['catalog_id' => $this->id, 'attribute_id' => $att->id])->one();
             }
         }
     }
     if (isset($this->__attributes[$attribute])) {
         return $this->__attributes[$attribute]->value;
     }
     return parent::__get($attribute);
 }
Esempio n. 19
0
 /**
  * PHP getter magic method. Override \yii\db\ActiveRecord so that we can automatically
  * setup any defined relationships if the method to set them up does not exist
  * as well as calling the method instead if it does exist (so we can push ActiveQueryInterface->multiple
  * values into ActiveRecordArray()
  * @param string $name property name
  * @return mixed property value
  * @see getAttribute()
  */
 public function __get($name)
 {
     if (!$this->isRelationPopulated($name) && $this->isDefinedRelation($name)) {
         if ($this->getIsNewRecord()) {
             // quite possible the new sub record is also new - let's check
             // to see if we can support the auto creation of the empty sub record
             $value = $this->getDefinedRelationship($name, true);
         } else {
             if (method_exists($this, 'get' . $name)) {
                 $method = new \ReflectionMethod($this, 'get' . $name);
                 $realName = lcfirst(substr($method->getName(), 3));
                 if ($realName !== $name) {
                     throw new \yii\base\InvalidParamException('Relation names are case sensitive. ' . get_class($this) . " has a relation named \"{$realName}\" instead of \"{$name}\".");
                 }
                 $value = call_user_func(array($this, 'get' . $name));
             } else {
                 // we will automatically apply this relation now
                 $value = $this->getDefinedRelationship($name);
             }
         }
         if ($value !== null) {
             if ($value instanceof ActiveQueryInterface) {
                 if ($value->multiple) {
                     // put result into a special ArrayObject extended object
                     $value2 = new ActiveRecordArray($value->all());
                 } else {
                     $value2 = $value->one();
                     if (is_null($value2) && !$this->getIsNewRecord()) {
                         // relational record does not exist yet so we will create an empty object now allowing user to start to populate values
                         $value2 = $this->getDefinedRelationship($name, true);
                     }
                 }
                 if ($value2 instanceof ActiveRecordArray) {
                     $value2->setDefaultObjectClass($this->getDefinedRelationInfo($name, 'class'));
                 }
                 if ($value2 instanceof ActiveRecordParentalInterface) {
                     $value2->setParentModel($this);
                 }
                 if ($value2 instanceof ActiveRecordReadOnlyInterface) {
                     $readOnly = $this->getDefinedRelationInfo($name, 'readOnly');
                     if ($readOnly !== null) {
                         $value2->setReadOnly($readOnly);
                     }
                     $canDelete = $this->getDefinedRelationInfo($name, 'canDelete');
                     if ($canDelete !== null) {
                         $value2->setCanDelete($canDelete);
                     }
                 }
                 $this->populateRelation($name, $value2);
                 return $value2;
             } elseif ($value instanceof ActiveRecordParentalInterface) {
                 $value->setParentModel($this);
                 if ($value instanceof ActiveRecordArray) {
                     $defaultClass = $this->getDefinedRelationInfo($name, 'class');
                     if ($defaultClass) {
                         $value->setDefaultObjectClass($defaultClass);
                     }
                 }
                 if ($value instanceof ActiveRecordReadOnlyInterface) {
                     $readOnly = $this->getDefinedRelationInfo($name, 'readOnly');
                     if ($readOnly !== null) {
                         $value->setReadOnly($readOnly);
                     }
                     $canDelete = $this->getDefinedRelationInfo($name, 'canDelete');
                     if ($canDelete !== null) {
                         $value->setCanDelete($canDelete);
                     }
                 }
                 $this->populateRelation($name, $value);
             } elseif ($value instanceof YiiActiveRecord) {
                 $this->populateRelation($name, $value);
             }
             return $value;
         }
     }
     return parent::__get($name);
 }