$behavior->$name = $value; return; } } if (method_exists($this, 'get' . $name)) { throw new InvalidCallException('Setting read-only property: ' . get_class($this) . '::' . $name); } throw new UnknownPropertyException('Setting unknown property: ' . get_class($this) . '::' . $name); } /** * Checks if a property is set, i.e. defined and not null. * This method will check in the following order and act accordingly: * * - a property defined by a setter: return whether the property is set * - a property of a behavior: return whether the property is set * - return `false` for non existing properties
* @param array $properties the property initial values given in terms of name-value pairs. * @return object the object itself */ public static function configure($object, $properties) { foreach ($properties as $name => $value) { $object->$name = $value; } return $object; } /**
* * @param array $config name-value pairs that will be used to initialize the object properties */ public function __construct($config = []) { if (!empty($config)) { Yii::configure($this, $config); } $this->init(); } /** * Initializes the object.
return $reflection->newInstanceArgs($dependencies); } if (!empty($dependencies) && $reflection->implementsInterface('yii\base\Configurable')) { // set $config as the last parameter (existing one will be overwritten) $dependencies[count($dependencies) - 1] = $config; return $reflection->newInstanceArgs($dependencies); } else { $object = $reflection->newInstanceArgs($dependencies); foreach ($config as $name => $value) { $object->$name = $value; } return $object;
public function get($class, $params = [], $config = []) { if (isset($this->_singletons[$class])) { // singleton return $this->_singletons[$class]; } elseif (!isset($this->_definitions[$class])) { return $this->build($class, $params, $config); } $definition = $this->_definitions[$class]; if (is_callable($definition, true)) { $params = $this->resolveDependencies($this->mergeParams($class, $params));
{ if (is_string($type)) { return static::$container->get($type, $params); } elseif (is_array($type) && isset($type['class'])) { $class = $type['class']; unset($type['class']); return static::$container->get($class, $params, $type); } elseif (is_callable($type, true)) { return static::$container->invoke($type, $params); } elseif (is_array($type)) { throw new InvalidConfigException('Object configuration must be an array containing a "class" element.'); }
$params = array_merge($type, $params); } else { $params['class'] = $type; } } return Yii::createObject($params); } /** * @inheritdoc */ public function init()
{ $validators = new ArrayObject; foreach ($this->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], $this, (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.'); } } return $validators;
* * @return ArrayObject|\yii\validators\Validator[] all the validators declared in the model. */ public function getValidators() { if ($this->_validators === null) { $this->_validators = $this->createValidators(); } return $this->_validators; } /** * Returns the validators applicable to the current [[scenario]].
* @return \yii\validators\Validator[] the validators applicable to the current [[scenario]]. */ public function getActiveValidators($attribute = null) { $validators = []; $scenario = $this->getScenario(); foreach ($this->getValidators() as $validator) { if ($validator->isActive($scenario) && ($attribute === null || in_array($attribute, $validator->getAttributeNames(), true))) { $validators[] = $validator; } } return $validators; }
* * @param string $attribute attribute name * @return bool whether the attribute is required */ public function isAttributeRequired($attribute) { foreach ($this->getActiveValidators($attribute) as $validator) { if ($validator instanceof RequiredValidator && $validator->when === null) { return true; } } return false; }
* @param $options array input options * @since 2.0.11 */ protected function addAriaAttributes(&$options) { if ($this->addAriaAttributes) { if (!isset($options['aria-required']) && $this->model->isAttributeRequired($this->attribute)) { $options['aria-required'] = 'true'; } if (!isset($options['aria-invalid'])) { if ($this->model->hasErrors($this->attribute)) { $options['aria-invalid'] = 'true'; }
* * @return $this the field object itself. */ public function dropDownList($items, $options = []) { $options = array_merge($this->inputOptions, $options); $this->addAriaAttributes($options); $this->adjustLabelFor($options); $this->parts['{input}'] = Html::activeDropDownList($this->model, $this->attribute, $items, $options); return $this; }
<label class="control-label"> Тема сообщения </label> </div> <div class="col-lg-6"> <?= $form->field($model, "title", ['options' => ['class' => 'b-submit__main-element']]) ->dropDownList(Feedback::getTitles(), ['class' => 'm-select field'])->label(false) ?> </div> </div> <div class="form-field row"> <div class="col-lg-2"> <label class="control-label"> Сообщение
{ $_obInitialLevel_ = ob_get_level(); ob_start(); ob_implicit_flush(false); extract($_params_, EXTR_OVERWRITE); try { require($_file_); return ob_get_clean(); } catch (\Exception $e) { while (ob_get_level() > $_obInitialLevel_) { if (!@ob_end_clean()) { ob_clean(); }
$this->renderers[$ext] = Yii::createObject($this->renderers[$ext]); } /* @var $renderer ViewRenderer */ $renderer = $this->renderers[$ext]; $output = $renderer->render($this, $viewFile, $params); } else { $output = $this->renderPhpFile($viewFile, $params); } $this->afterRender($viewFile, $params, $output); } array_pop($this->_viewFiles); $this->context = $oldContext;
* @throws InvalidCallException if the view cannot be resolved. * @see renderFile() */ public function render($view, $params = [], $context = null) { $viewFile = $this->findViewFile($view, $context); return $this->renderFile($viewFile, $params, $context); } /** * Finds the view file based on the given view name. * @param string $view the view name or the [path alias](guide:concept-aliases) of the view file. Please refer to [[render()]] * on how to specify this parameter.
* These parameters will not be available in the layout. * @return string the rendering result. * @throws InvalidParamException if the view file or the layout file does not exist. */ public function render($view, $params = []) { $content = $this->getView()->render($view, $params, $this); return $this->renderContent($content); } /** * Renders a static string by applying a layout. * @param string $content the static string being rendered
} } $this->bodyClass = 'credit-application'; return $this->render ('index',[ 'model'=>$model, ]); } }
$args = $this->controller->bindActionParams($this, $params); Yii::trace('Running action: ' . get_class($this->controller) . '::' . $this->actionMethod . '()', __METHOD__); if (Yii::$app->requestedParams === null) { Yii::$app->requestedParams = $args; } return call_user_func_array([$this->controller, $this->actionMethod], $args); } }
} $result = null; if ($runAction && $this->beforeAction($action)) { // run the action $result = $action->runWithParams($params); $result = $this->afterAction($action, $result); // call afterAction on modules foreach ($modules as $module) { /* @var $module Module */
$parts = $this->createController($route); if (is_array($parts)) { /* @var $controller Controller */ list($controller, $actionID) = $parts; $oldController = Yii::$app->controller; Yii::$app->controller = $controller; $result = $controller->runAction($actionID, $params); if ($oldController !== null) { Yii::$app->controller = $oldController; } return $result; }
$params = $this->catchAll; unset($params[0]); } try { Yii::trace("Route requested: '$route'", __METHOD__); $this->requestedRoute = $route; $result = $this->runAction($route, $params); if ($result instanceof Response) { return $result; } else { $response = $this->getResponse(); if ($result !== null) { $response->data = $result;
try { $this->state = self::STATE_BEFORE_REQUEST; $this->trigger(self::EVENT_BEFORE_REQUEST); $this->state = self::STATE_HANDLING_REQUEST; $response = $this->handleRequest($this->getRequest()); $this->state = self::STATE_AFTER_REQUEST; $this->trigger(self::EVENT_AFTER_REQUEST); $this->state = self::STATE_SENDING_RESPONSE; $response->send();
require(__DIR__ . '/../config/main.php'), require(__DIR__ . '/../config/main-local.php') ); $application = new yii\web\Application($config); $application->run();
$_SESSION = [ '__flash' => [], ];