* * @return array * * @throws InvalidConfigException */ public function getItems() { if (empty($this->items)) { if (empty($this->getTag())) return []; $tagQuestion = $this->getTagModel()->getChildren()->allAsArray(); $tree = []; $ids = ArrayHelper::getColumn($this->getQuestionAnswers(), 'id'); $treeQuestionsModels = Yii::$table->find('selected_tree') ->byId($ids)->orderBy(['lft' => SORT_ASC])->all(); foreach ($treeQuestionsModels as $treeQuestionsModel) { $children = $treeQuestionsModel->getChildren()->one();
* @return array the array representation of the object */ public function toArray(array $fields = [], array $expand = [], $recursive = true) { $data = []; foreach ($this->resolveFields($fields, $expand) as $field => $definition) { $attribute = is_string($definition) ? $this->$definition : $definition($this, $field); if ($recursive) { $nestedFields = $this->extractFieldsFor($fields, $field); $nestedExpand = $this->extractFieldsFor($expand, $field); if ($attribute instanceof Arrayable) { $attribute = $attribute->toArray($nestedFields, $nestedExpand);
* * @return mixed */ protected function prepareData() { $layout = $this->controller->getLayoutDataRender(); $data = Yii::createObject($this->getModelClass())->toArray(); return ArrayHelper::merge($layout, $data, ['firstLoad' => true]); } /** * Выполнить действие. *
* Выполнить действие. * * @return string */ public function run() { return $this->controller->render($this->getTemplate(), $this->prepareData()); } }
$args = $this->controller->bindActionParams($this, $params); Yii::debug('Running action: ' . get_class($this) . '::run(), invoked by ' . get_class($this->controller), __METHOD__); if (Yii::$app->requestedParams === null) { Yii::$app->requestedParams = $args; } if ($this->beforeRun()) { $result = call_user_func_array([$this, 'run'], $args); $this->afterRun(); return $result; } return null;
} $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::debug("Route requested: '$route'", __METHOD__); $this->requestedRoute = $route; $result = $this->runAction($route, $params); if ($result instanceof Response) { return $result; } $response = $this->getResponse(); if ($result !== null) {
{ 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();
$modulesConfig = Yii::createObject(ConfigComponent::class)->execute('frontend'); $config = ArrayHelper::merge($modulesConfig, $config); $config = ConfigModule::configRemove($config); $application = new Application($config); $application->run();
$_GET = [ 'tag' => '15', ]; $_SESSION = [ '__flash' => [], 'utm' => '', 'params' => '?tag=15', ];