本文整理匯總了PHP中yii\db\BaseActiveRecord::hasAttribute方法的典型用法代碼示例。如果您正苦於以下問題:PHP BaseActiveRecord::hasAttribute方法的具體用法?PHP BaseActiveRecord::hasAttribute怎麽用?PHP BaseActiveRecord::hasAttribute使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類yii\db\BaseActiveRecord
的用法示例。
在下文中一共展示了BaseActiveRecord::hasAttribute方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: __set
/**
* @inheritdoc
*/
public function __set($name, $value)
{
if ($this->_relation->hasAttribute($name) || $this->_relation->canGetProperty($name)) {
$this->_relation->{$name} = $value;
} else {
parent::__set($name, $value);
}
}
示例2: fillUpVariationModelDefaults
/**
* Fills up default attributes for the variation model.
* @param BaseActiveRecord $variationModel model instance.
* @throws InvalidConfigException on invalid configuration.
*/
private function fillUpVariationModelDefaults($variationModel)
{
if ($this->variationModelDefaultAttributes === null) {
$variationsRelation = $this->owner->getRelation($this->variationsRelation);
if (isset($variationsRelation->where)) {
foreach ((array) $variationsRelation->where as $attribute => $value) {
if ($variationModel->hasAttribute($attribute)) {
$variationModel->{$attribute} = $value;
}
}
}
return;
}
if (is_callable($this->variationModelDefaultAttributes, true)) {
call_user_func($this->variationModelDefaultAttributes, $variationModel);
return;
}
if (!is_array($this->variationModelDefaultAttributes)) {
throw new InvalidConfigException('"' . get_class($this) . '::variationModelDefaultAttributes" must be a valid callable or an array.');
}
foreach ($this->variationModelDefaultAttributes as $attribute => $value) {
$variationModel->{$attribute} = $value;
}
}