nstalled Yii extensions. Each array element represents a single extension
162 * with the following structure:
163 * 安装Yii扩展名列表。每个数组元素代表一个扩展
164 *
165 * ~~~
166 * [
167 * 'name' => 'extension name',
168 * 'version' => 'version number',
169 * 'bootstrap' => 'BootstrapClassName', // optional, may also be a configuration array
170 * 'alias' => [
171 * '@alias1' => 'to/path1',
172 * '@alias2' => 'to/path2',
173 * ],
174 * ]
175 * ~~~
176 *
177 * The "bootstrap" class listed above will be instantiated during the application
178 * [[bootstrap()|bootstrapping process]]. If the class implements [[BootstrapInterface]],
179 * its [[BootstrapInterface::bootstrap()|bootstrap()]] method will be also be called.
180 *
181 * If not set explicitly in the application config, this property will be populated with the contents of
182 * 如果在应用程序配置中没有设置,该属性将填充到内容
183 * @vendor/yiisoft/extensions.php`.
184 */
185 public $extensions;
186 /**
187 * @var array list of components that should be run during the application [[bootstrap()|bootstrapping process]].
188 * 组件的列表,运行在 [[bootstrap()|bootstrapping process]]中的应用
189 * Each component may be specified in one of the following formats:
190 *
191 * - an application component ID as specified via [[components]].
192 * - a module ID as specified via [[modules]].
193 * - a class name.
194 * - a configuration array.
195 *
196 * During the bootstrapping process, each component will be instantiated. If the component class
197 * implements [[BootstrapInterface]], its [[BootstrapInterface::bootstrap()|bootstrap()]] method
198 * will be also be called.
199 * 在整个启动过程中,每个组件被实例化。如果组件类提到 [[BootstrapInterface]],
200 * [[BootstrapInterface::bootstrap()|bootstrap()]]方法也会调用
201 */
202 public $bootstrap = [];
203 /**
204 * @var integer the current application state during a request handling life cycle.
205 * This property is managed by the application. Do not modify this property.
206 * 在请求处理生命周期中的当前应用程序状态。属性由应用程序管理。不要修改此属性。
207 */
208 public $state;
209 /**
210 * @var array list of loaded modules indexed by their class names.
211 * 加载模块列表由它们的类名称索引组成。
212 */
213 public $loadedModules = [];
214
215
216 /**
217 * Constructor.构造函数
218 * @param array $config name-value pairs that will be used to initialize the object properties.
219 * Note that the configuration must contain both [[id]] and [[basePath]].
220 * 用来初始化对象属性的 name-value 注意配置必须包含[[id]] 和[[basePath]].
221 * @throws InvalidConfigException if either [[id]] or [[basePath]] configuration is missing.
222 * 如果是修改[[id]] 或[[basePath]] 则配置丢失。
223 */
224 public function __construct($config = [])
225 {
226 Yii::$app = $this;// 将自身的实例绑到Yii的$app上
227 $this->setInstance($this);// 将自身加入到loadedModules中
228
229 $this->state = self::STATE_BEGIN;// 设置状态为刚开始
230
231 // 做预处理配置
232 $this->preInit($config);
233
234 $this->registerErrorHandler($config);
235
236 Component::__construct($config);
237 }
238
239 /**
240 * Pre-initializes the application. 初始化应用。
241 * This method is called at the beginning of the application constructor.
242 * It initializes several important application properties.
243 * 在构造函数中调用该方法,用于初始化一些重要的属性
244 * If you override this method, please make sure you call the parent implementation.
245 * @param array $config the application configuration 应用的配置
|