/
var
/
www
/
vhosts
/
nabawater
/
vendor
/
yiisoft
/
yii2
/
base
/
/var/www/vhosts/nabawater/vendor/yiisoft/yii2/base
mkdir
upload
Name
Size
Mode
Actions
Action.php
3809
0644
edit
dl
rm
ActionEvent.php
1280
0644
edit
dl
rm
ActionFilter.php
5206
0644
edit
dl
rm
Application.php
23934
0644
edit
dl
rm
Arrayable.php
3957
0644
edit
dl
rm
ArrayableTrait.php
9620
0644
edit
dl
rm
ArrayAccessTrait.php
2386
0644
edit
dl
rm
BaseObject.php
10570
0644
edit
dl
rm
Behavior.php
3208
0644
edit
dl
rm
BootstrapInterface.php
1992
0644
edit
dl
rm
Component.php
27876
0644
edit
dl
rm
Configurable.php
1050
0644
edit
dl
rm
Controller.php
19929
0644
edit
dl
rm
DynamicContentAwareInterface.php
1290
0644
edit
dl
rm
DynamicContentAwareTrait.php
2427
0644
edit
dl
rm
DynamicModel.php
7226
0644
edit
dl
rm
ErrorException.php
4143
0644
edit
dl
rm
ErrorHandler.php
12306
0644
edit
dl
rm
Event.php
11651
0644
edit
dl
rm
Exception.php
625
0644
edit
dl
rm
ExitException.php
998
0644
edit
dl
rm
InlineAction.php
1945
0644
edit
dl
rm
InvalidArgumentException.php
565
0644
edit
dl
rm
InvalidCallException.php
547
0644
edit
dl
rm
InvalidConfigException.php
545
0644
edit
dl
rm
InvalidParamException.php
631
0644
edit
dl
rm
InvalidRouteException.php
525
0644
edit
dl
rm
InvalidValueException.php
575
0644
edit
dl
rm
Model.php
39836
0644
edit
dl
rm
ModelEvent.php
538
0644
edit
dl
rm
Module.php
28005
0644
edit
dl
rm
NotSupportedException.php
546
0644
edit
dl
rm
Object.php
1042
0644
edit
dl
rm
Request.php
3150
0644
edit
dl
rm
Response.php
1117
0644
edit
dl
rm
Security.php
31893
0644
edit
dl
rm
StaticInstanceInterface.php
1008
0644
edit
dl
rm
StaticInstanceTrait.php
1078
0644
edit
dl
rm
Theme.php
6712
0644
edit
dl
rm
UnknownClassException.php
527
0644
edit
dl
rm
UnknownMethodException.php
556
0644
edit
dl
rm
UnknownPropertyException.php
549
0644
edit
dl
rm
UserException.php
436
0644
edit
dl
rm
View.php
21792
0644
edit
dl
rm
ViewContextInterface.php
657
0644
edit
dl
rm
ViewEvent.php
1096
0644
edit
dl
rm
ViewNotFoundException.php
529
0644
edit
dl
rm
ViewRenderer.php
856
0644
edit
dl
rm
Widget.php
10609
0644
edit
dl
rm
WidgetEvent.php
838
0644
edit
dl
rm
Edit:
/var/www/vhosts/nabawater/vendor/yiisoft/yii2/base/DynamicModel.php
(7226B)
<?php /** * @link http://www.yiiframework.com/ * @copyright Copyright (c) 2008 Yii Software LLC * @license http://www.yiiframework.com/license/ */ namespace yii\base; use yii\validators\Validator; /** * DynamicModel is a model class primarily used to support ad hoc data validation. * * The typical usage of DynamicModel is as follows, * * ```php * public function actionSearch($name, $email) * { * $model = DynamicModel::validateData(compact('name', 'email'), [ * [['name', 'email'], 'string', 'max' => 128], * ['email', 'email'], * ]); * if ($model->hasErrors()) { * // validation fails * } else { * // validation succeeds * } * } * ``` * * The above example shows how to validate `$name` and `$email` with the help of DynamicModel. * The [[validateData()]] method creates an instance of DynamicModel, defines the attributes * using the given data (`name` and `email` in this example), and then calls [[Model::validate()]]. * * You can check the validation result by [[hasErrors()]], like you do with a normal model. * You may also access the dynamic attributes defined through the model instance, e.g., * `$model->name` and `$model->email`. * * Alternatively, you may use the following more "classic" syntax to perform ad-hoc data validation: * * ```php * $model = new DynamicModel(compact('name', 'email')); * $model->addRule(['name', 'email'], 'string', ['max' => 128]) * ->addRule('email', 'email') * ->validate(); * ``` * * DynamicModel implements the above ad-hoc data validation feature by supporting the so-called * "dynamic attributes". It basically allows an attribute to be defined dynamically through its constructor * or [[defineAttribute()]]. * * @author Qiang Xue <qiang.xue@gmail.com> * @since 2.0 */ class DynamicModel extends Model { private $_attributes = []; /** * Constructors. * @param array $attributes the dynamic attributes (name-value pairs, or names) being defined * @param array $config the configuration array to be applied to this object. */ public function __construct(array $attributes = [], $config = []) { foreach ($attributes as $name => $value) { if (is_int($name)) { $this->_attributes[$value] = null; } else { $this->_attributes[$name] = $value; } } parent::__construct($config); } /** * {@inheritdoc} */ public function __get($name) { if ($this->hasAttribute($name)) { return $this->_attributes[$name]; } return parent::__get($name); } /** * {@inheritdoc} */ public function __set($name, $value) { if ($this->hasAttribute($name)) { $this->_attributes[$name] = $value; } else { parent::__set($name, $value); } } /** * {@inheritdoc} */ public function __isset($name) { if ($this->hasAttribute($name)) { return isset($this->_attributes[$name]); } return parent::__isset($name); } /** * {@inheritdoc} */ public function __unset($name) { if ($this->hasAttribute($name)) { unset($this->_attributes[$name]); } else { parent::__unset($name); } } /** * {@inheritdoc} */ public function canGetProperty($name, $checkVars = true, $checkBehaviors = true) { return parent::canGetProperty($name, $checkVars, $checkBehaviors) || $this->hasAttribute($name); } /** * {@inheritdoc} */ public function canSetProperty($name, $checkVars = true, $checkBehaviors = true) { return parent::canSetProperty($name, $checkVars, $checkBehaviors) || $this->hasAttribute($name); } /** * Returns a value indicating whether the model has an attribute with the specified name. * @param string $name the name of the attribute * @return bool whether the model has an attribute with the specified name. * @since 2.0.16 */ public function hasAttribute($name) { return array_key_exists($name, $this->_attributes); } /** * Defines an attribute. * @param string $name the attribute name * @param mixed $value the attribute value */ public function defineAttribute($name, $value = null) { $this->_attributes[$name] = $value; } /** * Undefines an attribute. * @param string $name the attribute name */ public function undefineAttribute($name) { unset($this->_attributes[$name]); } /** * Adds a validation rule to this model. * You can also directly manipulate [[validators]] to add or remove validation rules. * This method provides a shortcut. * @param string|array $attributes the attribute(s) to be validated by the rule * @param mixed $validator the validator for the rule.This can be a built-in validator name, * a method name of the model class, an anonymous function, or a validator class name. * @param array $options the options (name-value pairs) to be applied to the validator * @return $this the model itself */ public function addRule($attributes, $validator, $options = []) { $validators = $this->getValidators(); $validators->append(Validator::createValidator($validator, $this, (array)$attributes, $options)); return $this; } /** * Validates the given data with the specified validation rules. * This method will create a DynamicModel instance, populate it with the data to be validated, * create the specified validation rules, and then validate the data using these rules. * @param array $data the data (name-value pairs) to be validated * @param array $rules the validation rules. Please refer to [[Model::rules()]] on the format of this parameter. * @return static the model instance that contains the data being validated * @throws InvalidConfigException if a validation rule is not specified correctly. */ public static function validateData(array $data, $rules = []) { /* @var $model DynamicModel */ $model = new static($data); if (!empty($rules)) { $validators = $model->getValidators(); foreach ($rules as $rule) { if ($rule instanceof Validator) { $validators->append($rule); } elseif (is_array($rule) && isset($rule[0], $rule[1])) { // attributes, validator type $validator = Validator::createValidator($rule[1], $model, (array)$rule[0], array_slice($rule, 2)); $validators->append($validator); } else { throw new InvalidConfigException('Invalid validation rule: a rule must specify both attribute names and validator type.'); } } } $model->validate(); return $model; } /** * {@inheritdoc} */ public function attributes() { return array_keys($this->_attributes); } }
Save
cmd:
run