yii2源码学习笔记(二十)】的更多相关文章

Widget类是所有部件的基类.yii2\base\Widget.php <?php /** * @link http://www.yiiframework.com/ * @copyright Copyright (c) 2008 Yii Software LLC * @license http://www.yiiframework.com/license/ */ namespace yii\base; use Yii; use ReflectionClass; /** * Widget is…
View继承了component,用于渲染视图文件:yii2\base\View.php <?php /** * @link http://www.yiiframework.com/ * @copyright Copyright (c) 2008 Yii Software LLC * @license http://www.yiiframework.com/license/ */ namespace yii\base; use Yii; use yii\helpers\FileHelper; u…
yii\base\Object代码详解 <?php /** * @link http://www.yiiframework.com/ * @copyright Copyright (c) 2008 Yii Software LLC * @license http://www.yiiframework.com/license/ */ namespace yii\base; use Yii; /** * Object is the base class that implements the *pr…
Application是所有应用程序类的基类,接下来了解一下它的源码.yii2\base\Application.php. <?php /** * @link http://www.yiiframework.com/ * @copyright Copyright (c) 2008 Yii Software LLC * @license http://www.yiiframework.com/license/ */ namespace yii\base; use Yii; /** * Applic…
Action是所有控制器的基类,接下来了解一下它的源码.yii2\base\Action.php <?php /** * @link http://www.yiiframework.com/ * @copyright Copyright (c) 2008 Yii Software LLC * @license http://www.yiiframework.com/license/ */ namespace yii\base; use Yii; /** * Action is the base…
笔记一里记录,jQuery的总体结构如下: (function( global, factory ) { //调用factory(工厂)生成jQuery实例 factory( global ); }(typeof window !== "undefined" ? window : this, function( window, noGlobal ) { //factory实现,jquery源码主体部分 })); 那么这个生成jQuery的工厂是咋样的? 酱紫的: function( w…
Action 的概述 InlineAction 就是内联动作,所谓的内联动作就是放到controller 里面的 actionXXX 这种 Action.customAction 就是独立动作,就是直接继承 Action 并实现 run 方法的 Action. 与 Controller 的交互 public function createAction($id) { if ($id === '') { $id = $this->defaultAction; } $actionMap = $this…
//添加实例属性和方法 jQuery.fn = jQuery.prototype = { // 版本,使用方式:$().jquery弹出当前引入的jquery的版本 jquery: core_version, // 修正指向问题(后有详解) constructor: jQuery, // 初始化和参数管理 init: function( selector, context, rootjQuery ) { var match, elem; // 写错之后的处理,如果写成: $(""),…
继续了解controller基类. /** * Runs a request specified in terms of a route.在路径中指定的请求. * The route can be either an ID of an action within this controller or a complete route consisting * of module IDs, controller ID and action ID. If the route starts with…
Module类是模块和应用类的基类. yiisoft\yii2\base\Module.php <?php /** * @link http://www.yiiframework.com/ * @copyright Copyright (c) 2008 Yii Software LLC * @license http://www.yiiframework.com/license/ */ namespace yii\base; use Yii; use yii\di\ServiceLocator;…
view剩余代码 /** * @return string|boolean the view file currently being rendered. False if no view file is being rendered. * 当前正在渲染的视图文件 */ public function getViewFile() { return end($this->_viewFiles); } /** * This method is invoked right before [[rende…
继续了解Application. /** * Registers the errorHandler component as a PHP error handler. * 注册errorHandler组件作为PHP错误处理函数 * @param array $config application config 应用程序配置 */ protected function registerErrorHandler(&$config) { if (YII_ENABLE_ERROR_HANDLER) {/…
Module类的最后代码 /** * Registers sub-modules in the current module. * 注册子模块到当前模块 * Each sub-module should be specified as a name-value pair, where * name refers to the ID of the module and value the module or a configuration * array that can be used to c…
这几天有点忙今天好些了,继续上次的module来吧 /** * Returns the directory that contains the controller classes according to [[controllerNamespace]]. *根据控制器的命名空间返回控制器的目录路径 * Note that in order for this method to return a value, you must define * an alias for the root nam…
Theme 类,应用的主题,通过替换路径实现主题的应用,方法为获取根路径和根链接:yii2\base\Theme.php <?php /** * @link http://www.yiiframework.com/ * @copyright Copyright (c) 2008 Yii Software LLC * @license http://www.yiiframework.com/license/ */ namespace yii\base; use Yii; use yii\helpe…
模型类DynamicModel主要用于实现模型内的数据验证yii2\base\DynamicModel.php <?php /** * @link http://www.yiiframework.com/ * @copyright Copyright (c) 2008 Yii Software LLC * @license http://www.yiiframework.com/license/ */ namespace yii\base; use yii\validators\Validato…
Controller控制器类,是所有控制器的基类,用于调用模型和布局. <?php /** * @link http://www.yiiframework.com/ * @copyright Copyright (c) 2008 Yii Software LLC * @license http://www.yiiframework.com/license/ */ namespace yii\base; use Yii; /** * Controller is the base class for…
Behvaior类,Behavior类是所有事件类的基类: 目录yii2\base\Behavior.php <?php /** * @link http://www.yiiframework.com/ * @copyright Copyright (c) 2008 Yii Software LLC * @license http://www.yiiframework.com/license/ */ namespace yii\base; /** * Behavior is the base c…
Event是所有事件类的基类.它封装了与事件相关的参数. yii2\base\Event.php <?php /** * @link http://www.yiiframework.com/ * @copyright Copyright (c) 2008 Yii Software LLC * @license http://www.yiiframework.com/license/ */ namespace yii\base; /** * Event is the base class for…
assets   前端资源文件夹,用于管理css js等前端资源文件等 commands   包含命令行命令,文件为控制器文件 config 应用的配置文件 controllers 控制器文件 mail  (应用的前后台和命令行的与邮件相关的布局文件等) modles 模型文件 runtime 程序运行时生成的临时文件 tests     用于各种测试程序的测试类文件 vendor  就是各种第三方的程序. 这是Composer安装的其他程序的存放目录,包含Yii框架本身. 如果你向compos…
今天继续了解model类 /** 2 * Returns the form name that this model class should use. 3 * 4 * 返回表单的名称,就是这个 model 的类名 5 * 6 * The form name is mainly used by [[\yii\widgets\ActiveForm]] to determine how to name 7 * the input fields for the attributes in a mode…
继续了解组件Component.php /** * Returns a value indicating whether a property is defined for this component. * A property is defined if: * * - the class has a getter or setter method associated with the specified name * (in this case, property name is case…
组件(component),是Yii框架的基类,实现了属性.事件.行为三类功能,如果需要事件和行为的功能,需要继承该类. yii\base\Component代码详解 <?php /** * @link http://www.yiiframework.com/ * @copyright Copyright (c) 2008 Yii Software LLC * @license http://www.yiiframework.com/license/ */ namespace yii\base;…
类图关系 属性与方法 class Component extends BaseObject { private $_events = []; private $_eventWildcards = []; private $_behaviors; public function __get($name) public function __set($name, $value) public function __isset($name) public function __unset($name)…
关系类图 从上图可以看出 Application 类继承了 Module,在框架中的是非常重要角色. 加载配置 public function setModules($modules) { foreach ($modules as $id => $module) { $this->_modules[$id] = $module; } } base\Module 通过 setModules 把 Module 配置信息加载进来,赋值给 私有变量 _modules. 解析路由 Module 还有一个…
jquery源码学习笔记二:jQuery工厂 jquery源码学习笔记一:总体结构 上两篇说过,query的核心是一个jQuery工厂.其代码如下 function( window, noGlobal ) { var jQuery = function( selector, context ) {//首先定义一个内部jQuery.注意,此jQuery只是一个工厂内部的变量,并非我们在外面引用的那个jQuery或$ return new jQuery.fn.init( selector, cont…
版本 Underscore.js 1.9.1 一共 1693 行.注释我就删了,太长了… 整体是一个 (function() {...}());  这样的东西,我们应该知道这是一个 IIFE(立即执行函数). var root = typeof self == 'object' && self.self === self && self || typeof global == 'object' && global.global === global &…
HashMap有一个问题,就是迭代HashMap的顺序并不是HashMap放置的顺序,也就是无序. LinkedHashMap保证了元素迭代的顺序.该迭代顺序可以是插入顺序或者是访问顺序.通过维护一个双向链表实现. 需要在理解HashMap实现原理的基础上学习LinkedHashMap,JDK源码学习笔记——HashMap 一.数据结构 实际上就是在HashMap的基础上加了LinkedList (图片来自Java集合之LinkedHashMap) LinkedHashMap.Entry继承了H…
系列文章: 1.async-validator 源码学习(一):文档翻译 2.async-validator 源码学习笔记(二):目录结构 rule 主要实现的是校验规则,文件结构为下图: 一.rule 目录文件介绍 其中 index.d.ts 文件: declare const _default: { required: import("..").ExecuteRule; whitespace: import("..").ExecuteRule; type: im…
系列文章: 1.async-validator 源码学习(一):文档翻译 2.async-validator 源码学习笔记(二):目录结构 3.async-validator 源码学习笔记(三):rule 源码目录结构如图: validator 源码分析 validator 与 rule 紧密相连,rule 目录下的文件主要功能是校验 value 和 rule ,然后给 errors 数组中添加 error .validator 则是把 校验的 value 细分成各种类型,对不同的类型进行不同的…