* @throws InvalidConfigException if the table for the AR class does not exist. */ public static function getTableSchema() { $tableSchema = static::getDb() ->getSchema() ->getTableSchema(static::tableName()); if ($tableSchema === null) { throw new InvalidConfigException('The table does not exist: ' . static::tableName()); } return $tableSchema; } /** * Returns the primary key name(s) for this AR class. * The default implementation will return the primary key(s) as declared * in the DB table that is associated with this AR class.
* Returns the list of all attribute names of the model. * The default implementation will return all column names of the table associated with this AR class. * @return array list of attribute names. */ public function attributes() { return array_keys(static::getTableSchema()->columns); } /** * Declares which DB operations should be performed within a transaction in different scenarios. * The supported DB operations are: [[OP_INSERT]], [[OP_UPDATE]] and [[OP_DELETE]], * which correspond to the [[insert()]], [[update()]] and [[delete()]] methods, respectively.
* 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. */ public function hasAttribute($name) { return isset($this->_attributes[$name]) || in_array($name, $this->attributes(), true); } /** * Returns the named attribute value. * If this record is the result of a query and the attribute is not loaded, * `null` will be returned.
* @see getAttribute() */ public function __get($name) { if (isset($this->_attributes[$name]) || array_key_exists($name, $this->_attributes)) { return $this->_attributes[$name]; } elseif ($this->hasAttribute($name)) { return null; } else { if (isset($this->_related[$name]) || array_key_exists($name, $this->_related)) { return $this->_related[$name]; } $value = parent::__get($name);
public static function getAttributeValue($model, $attribute) { if (!preg_match('/(^|.*\])([\w\.]+)(\[.*|$)/', $attribute, $matches)) { throw new InvalidParamException('Attribute name must contain word characters only.'); } $attribute = $matches[2]; $value = $model->$attribute; if ($matches[3] !== '') { foreach (explode('][', trim($matches[3], '[]')) as $id) { if ((is_array($value) || $value instanceof \ArrayAccess) && isset($value[$id])) { $value = $value[$id]; } else { return null;
* See [[renderTagAttributes()]] for details on how attributes are being rendered. * @return string the generated input tag */ public static function activeInput($type, $model, $attribute, $options = []) { $name = isset($options['name']) ? $options['name'] : static::getInputName($model, $attribute); $value = isset($options['value']) ? $options['value'] : static::getAttributeValue($model, $attribute); if (!array_key_exists('id', $options)) { $options['id'] = static::getInputId($model, $attribute); } return static::input($type, $name, $value, $options); }
* * @return string the generated input tag */ public static function activeTextInput($model, $attribute, $options = []) { self::normalizeMaxLength($model, $attribute, $options); return static::activeInput('text', $model, $attribute, $options); } /** * Generates a hidden input tag for the given model attribute. * This method will generate the "name" and "value" tag attributes automatically for the model attribute * unless they are explicitly specified in `$options`.
*/ public function textInput($options = []) { $options = array_merge($this->inputOptions, $options); $this->addAriaAttributes($options); $this->adjustLabelFor($options); $this->parts['{input}'] = Html::activeTextInput($this->model, $this->attribute, $options); return $this; } /** * Renders a hidden input.
'error' => '', 'hint' => '', ], ], ]); ?> <?= $form->field($model, 'event')->textInput(['maxlength' => true])->hint(Yii::t('app', 'Event name and date')) ?> <?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?> <?= $form->field($model, 'email')->textInput(['maxlength' => true]) ?> <?= $form->field($model, 'phone')->textInput(['maxlength' => true]) ?> <?= $form->field($model, 'phone_connected')->textInput(['maxlength' => true]) ?> </br><p class="text-center"><strong><?= Yii::t('app', 'Your professional activity') ?></strong></p> <?= $form->field($model, 'media_name')->textInput(['maxlength' => true]) ?>
*/ public function renderPhpFile($_file_, $_params_ = []) { ob_start(); ob_implicit_flush(false); extract($_params_, EXTR_OVERWRITE); require($_file_); return ob_get_clean(); } /** * Renders dynamic content returned by the given PHP statements.
$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 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
if ($model->load(Yii::$app->request->post()) && $model->save()) { Yii::$app->session->setFlash('success', 'Спасибо. Заявка отправлена на рассмотрение.'); return $this->goHome(); } else { 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__ . '/../../common/config/main-local.php'), require(__DIR__ . '/../config/main.php'), require(__DIR__ . '/../config/main-local.php') ); $application = new yii\web\Application($config); $application->run();