} if (is_array($rule) === true) { if (isset($rule['routes']) === true && is_array($rule['routes']) === true) { $first = true; foreach ($rule['routes'] as $pattern => $route) { if ($first === true) { $module = \app\models\Module::findOne(['route' => $route]); if (is_null($module) === true) { throw new \yii\base\InvalidConfigException("Route {$route} not found in modules table"); } } $rule = $this->_getUrlRule($route, $pattern, $module); if (!$rule instanceof UrlRuleInterface) { throw new InvalidConfigException('URL rule class must implement UrlRuleInterface.'); } $compiledRules[] = $rule;
Yii::warning('Unable to use cache for URL manager: ' . $e->getMessage()); } } if (empty($this->rules)) { return; } $this->rules = $this->buildRules($this->rules); } /** * Adds additional URL rules. * * This method will call [[buildRules()]] to parse the given rule declarations and then append or insert
$this->_initLanguageUrl();//видимо устанавливает дефолт язык при загрузке приложения $langList = Language::getList(); $currentLang = Language::getCurrent(); Yii::$app->language = $langList[$currentLang];//устанавливает текущий язык в приложение parent::init(); // dd($pattern); } private function _initLanguageUrl()//в зависимости от того что в строке запишет в сессию язык или установит дефолтный { $langId = Yii::$app->getRequest()->getPathLanguage();
*/ public function __construct($config = []) { if (!empty($config)) { Yii::configure($this, $config); } $this->init(); } /** * Initializes the object. * This method is invoked at the end of the constructor after the object is initialized with the * given configuration.
$config = $this->resolveDependencies($config); 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); } $object = $reflection->newInstanceArgs($dependencies); foreach ($config as $name => $value) { $object->$name = $value; }
$class = $class->id; } 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));
return static::$container->get($class, $params, $type); } if (isset($type['class'])) { $class = $type['class']; unset($type['class']); return static::$container->get($class, $params, $type); } throw new InvalidConfigException('Object configuration must be an array containing a "class" or "__class" element.'); } private static $_logger;
if (isset($this->_definitions[$id])) { $definition = $this->_definitions[$id]; if (is_object($definition) && !$definition instanceof Closure) { return $this->_components[$id] = $definition; } return $this->_components[$id] = Yii::createObject($definition); } elseif ($throwException) { throw new InvalidConfigException("Unknown component ID: $id"); } return null; }
* Since version 2.0.13, if a component isn't defined in the module, it will be looked up in the parent module. * The parent module may be the application. */ public function get($id, $throwException = true) { if (!isset($this->module)) { return parent::get($id, $throwException); } $component = parent::get($id, false); if ($component === null) { $component = $this->module->get($id, $throwException); }
/** * Returns the URL manager for this application. * @return \yii\web\UrlManager the URL manager for this application. */ public function getUrlManager() { return $this->get('urlManager'); } /** * Returns the internationalization (i18n) component. * @return \yii\i18n\I18N the internationalization application component. */
$app->getResponse()->on(Response::EVENT_AFTER_PREPARE, [$this, 'setDebugHeaders']); }); $app->on(Application::EVENT_BEFORE_ACTION, function () use ($app) { $app->getView()->on(View::EVENT_END_BODY, [$this, 'renderToolbar']); }); $app->getUrlManager()->addRules([ [ 'class' => $this->urlRuleClass, 'route' => $this->id, 'pattern' => $this->id, 'normalizer' => false, 'suffix' => false
if (!isset($component)) { $component = Yii::createObject($mixed); } if ($component instanceof BootstrapInterface) { Yii::debug('Bootstrap with ' . get_class($component) . '::bootstrap()', __METHOD__); $component->bootstrap($this); } else { Yii::debug('Bootstrap with ' . get_class($component), __METHOD__); } } }
protected function bootstrap() { $request = $this->getRequest(); Yii::setAlias('@webroot', dirname($request->getScriptFile())); Yii::setAlias('@web', $request->getBaseUrl()); parent::bootstrap(); } /** * Handles the specified request. * @param Request $request the request to be handled * @return Response the resulting response
/** * {@inheritdoc} */ public function init() { $this->state = self::STATE_INIT; $this->bootstrap(); } /** * Initializes extensions and executes bootstrap components. * This method is called by [[init()]] after the application has been fully configured. * If you override this method, make sure you also call the parent implementation.
*/ public function __construct($config = []) { if (!empty($config)) { Yii::configure($this, $config); } $this->init(); } /** * Initializes the object. * This method is invoked at the end of the constructor after the object is initialized with the * given configuration.
$this->state = self::STATE_BEGIN; $this->preInit($config); $this->registerErrorHandler($config); Component::__construct($config); } /** * Pre-initializes the application. * This method is called at the beginning of the application constructor. * It initializes several important application properties.
require(__DIR__ . '/../dd.php'); $config = yii\helpers\ArrayHelper::merge( require(__DIR__ . '/../config/web.php'), require(__DIR__ . '/../config/frontend.php') ); (new yii\web\Application($config))->run();
$_SESSION = [ '__flash' => [], 'LANGUAGE_CURRENT' => 2, ];