本文整理匯總了PHP中yii\base\Object::__set方法的典型用法代碼示例。如果您正苦於以下問題:PHP Object::__set方法的具體用法?PHP Object::__set怎麽用?PHP Object::__set使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類yii\base\Object
的用法示例。
在下文中一共展示了Object::__set方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: __set
/**
* @param string $name
* @param mixed $value
*/
public function __set($name, $value)
{
try {
parent::__set($name, $value);
} catch (UnknownPropertyException $e) {
}
}
示例2: __set
/**
* Sets value of a property.
*
* @param string $name the property name or the event name
* @param mixed $value the property value
* @throws UnknownPropertyException if the property is not defined
* @throws InvalidCallException if the property is read-only
* @see __get()
*/
public function __set($name, $value)
{
if (isset($this->_data[$name])) {
$this->_data[$name] = $value;
} else {
parent::__set($name, $value);
}
}
示例3: __set
/**
* @param string $name
* @param mixed $value
* @throws \yii\base\UnknownPropertyException
*/
public function __set($name, $value)
{
if ($this->canSetProperty($name)) {
parent::__set($name, $value);
} else {
$this->model->{$name} = $value;
}
}
示例4: __set
public function __set($name, $value)
{
if (strncmp($name, 'on ', 3) === 0) {
$this->events[trim(substr($name, 3))] = $value;
return;
} else {
parent::__set($name, $value);
}
}
示例5: __set
/**
* @inheritdoc
* @throws \yii\base\InvalidParamException
*/
public function __set($name, $value)
{
if (array_key_exists($name, $this->_color)) {
if ($value >= 0 && $value <= 255) {
return $this->_color[$name] = $value;
} else {
throw new InvalidParamException('Wrong RGB value');
}
}
parent::__set($name, $value);
}
示例6: __set
/**
* @inheritdoc
*/
public function __set($name, $value)
{
// setters go first
$setter = 'set' . $name;
if (method_exists($this, $setter)) {
$this->{$setter}($value);
} elseif (array_key_exists($name, $this->options)) {
$this->options[$name] = $value;
} else {
parent::__set($name, $value);
}
}