ZendFramework-2.4 源代码 - 关于Module - 模块入口文件
<?php
// /data/www/www.domain.com/www/module/Album/Module.php
namespace Album; use Zend\ModuleManager\Feature\AutoloaderProviderInterface;
use Zend\ModuleManager\Feature\ConfigProviderInterface;
use Zend\ModuleManager\Feature\InitProviderInterface;
use Zend\ModuleManager\Feature\BootstrapListenerInterface;
use Zend\ModuleManager\Feature\LocatorRegisteredInterface;
use Zend\ModuleManager\Feature\DependencyIndicatorInterface;
use Zend\ModuleManager\ModuleManagerInterface;
use Zend\EventManager\EventInterface; use Album\Model\Album;
use Album\Model\AlbumTable;
use Zend\Db\ResultSet\ResultSet;
use Zend\Db\TableGateway\TableGateway; /* AutoloaderProviderInterface : loadModule---0 : invoke <getAutoloaderConfig> method */
/* DependencyIndicatorInterface : loadModule---1 : invoke <getModuleDependencies> method */
/* InitProviderInterface : loadModule---2 : invoke <init> method */
/* BootstrapListenerInterface : loadModule---3 : bind <onBootstrap> method into SharedEventManager */
// LocatorRegisteredInterface /* loadModule---4 : inject into LocatorRegisteredInterface */
/* ConfigProviderInterface : loadModule---5 : invoke <getConfig> method */
class Module implements AutoloaderProviderInterface,
DependencyIndicatorInterface,
InitProviderInterface,
BootstrapListenerInterface,
ConfigProviderInterface
{ /**
* loadModule---0
* Zend\ModuleManager\Listener\AutoloaderListener::__invoke(ModuleEvent $e) 调用本方法
* 在触发"loadModule"事件时调用
*/
public function getAutoloaderConfig()
{
// return array(); //使用 Composer 加载
return array(
'Zend\Loader\ClassMapAutoloader' => array(
__DIR__ . '/autoload_classmap.php'
),
'Zend\Loader\StandardAutoloader' => array(
'namespaces' => array(
__NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__
)
)
);
} /**
* loadModule---1
* Zend\ModuleManager\Listener\ModuleDependencyCheckerListener::__invoke(ModuleEvent $e) 调用本方法
* 在触发"loadModule"事件时调用
*/
public function getModuleDependencies(){
return array();
} /**
* loadModule---2
* Zend\ModuleManager\Listener\InitTrigger::__invoke(ModuleEvent $e) 调用本方法
* 在触发"loadModule"事件时调用
*/
public function init(ModuleManagerInterface $modulemanager){
// 无需返回参数
// $modulemanager instanceof Zend\ModuleManager\ModuleManager
$moduleEvent = $modulemanager->getEvent(); // 获取当前模块
$module = $moduleEvent->getModule(); // $module == $this // 获取服务管理器
$serviceManager = $moduleEvent->getParam('ServiceManager',null);
$applicationConfig = $serviceManager->get('ApplicationConfig'); // 获取配置监听器
$configListener = $moduleEvent->getParam('configListener',null);
$configListener = $moduleEvent->getConfigListener(); // 获取事件管理器
$eventManager = $modulemanager->getEventManager();
$sharedEvents = $eventManager->getSharedManager(); // 获取模块管理器中模块列表
$modulemanager->getModules() == array(
'Application',
'Album'
);
} /**
* loadModule---3
* Zend\ModuleManager\Listener\OnBootstrapListener::__invoke(ModuleEvent $e) 注册本方法到共享事件管理器,事件为“bootstrap”
* 在触发"bootstrap"事件时调用
*
*/
public function onBootstrap(EventInterface $e){
} /**
* loadModule---5
* Zend\ModuleManager\Listener\ConfigListener::onLoadModule(ModuleEvent $e) 调用本方法
* 在触发"loadModule"事件时调用
* $this->configs['album'] = getConfig();
*/
public function getConfig()
{
return include __DIR__ . '/config/module.config.php';
} /**
* loadModule---6
* Zend\ModuleManager\Listener\ServiceListener::onLoadModule(ModuleEvent $e) 调用本方法
*
* if($module instanceof $sm['module_class_interface']){
* $config = $module->{$sm['module_class_method']}();
* $this->serviceManagers[$key]['configuration'][$fullname] = $config;
* }
*
* -----------
* $serviceListener->addServiceManager($serviceLocator,
* 'service_manager',
* 'Zend\ModuleManager\Feature\ServiceProviderInterface',
* 'getServiceConfig'
* ) 添加的服务,决定了本方法会被调用
*/
public function getServiceConfig()
{
return array(
'factories' => array(
'Album\Model\AlbumTable' => function ($sm)
{
$tableGateway = $sm->get('AlbumTableGateway');
$table = new AlbumTable($tableGateway);
return $table;
},
'AlbumTableGateway' => function ($sm)
{
$dbAdapter = $sm->get('Zend\Db\Adapter\Adapter');
$resultSetPrototype = new ResultSet();
$resultSetPrototype->setArrayObjectPrototype(new Album());
return new TableGateway('album', $dbAdapter, null, $resultSetPrototype);
}
)
);
}
}
ZendFramework-2.4 源代码 - 关于Module - 模块入口文件的更多相关文章
- DISCUZ论坛各大功能模块入口文件介绍
index.php 首页入口文件,这个文件相信大家都不陌生,小编就不具体介绍了. forum.php 论坛入口文件 portal.php 门户入口文件 group.php 群组入口文件 home.ph ...
- webpack 配置多入口文件,输出多出口文件
const path = require('path') module.exports = { // 入口文件的配置项 entry: { // 入口文件 entry: './src/entry.js' ...
- thinkphp 的两种建构模式 第一种一个单入口里面定义两个模块,前台和后台,函数控制模块必须function.php前台加载前台模块的汉书配置文件,后台加载后台模块的汉书配置文件,公共文件共用。第二种架构模式两个单入口文件,分别生成两个应用定义define。。。函数可以定义配置文件。。。。
thinkphp 的两种建构模式 第一种一个单入口里面定义两个模块,前台和后台,函数控制模块必须function.php前台加载前台模块的汉书配置文件,后台加载后台模块的汉书配置文件,公共文件共用. ...
- Ubuntu Server 14.04 & Apache2.4 虚拟主机、模块重写、隐藏入口文件配置
环境: Ubuntu Server 14.04 , Apache2.4 一.Apache2.4 虚拟主机配置 01. 新建一份配置文件 在apache2.4中,虚拟主机的目录是通过/etc/apach ...
- thinkphp3.2后台模块怎么添加(admin),直接复制Home?还是在入口文件生成?
1.都可以,复制home改下命名空间也行,在入口添加下参数自动生成也行 2ThinkPHP3.2后支持模块化开发,在Home目录的同级目录下创建一个新的文件夹,命名为Admin,或者就如你自己所说,直 ...
- JavaScript ES6 module 模块
在使用JavaScript开发大型项目时,模块开发概念是一个必须考虑的问题.其目的就是通过命名空间对各类业务对象进行一定的封装,防止命名冲突. 本篇着重介绍ES6 module中的export和imp ...
- 利用Module模块把构建的神经网络跑起来
训练一个神经网络往往只需要简单的几步: 准备训练数据 初始化模型的参数 模型向往计算与向后计算 更新模型参数 设置相关的checkpoint 如果上述的每个步骤都需要我们写Python的代码去一步步实 ...
- thttpd源代码解析 定时器模块
thttpd源代码解析 定时器模块 thttpd是很轻量级的httpserver,可运行文件仅50kB.名称中的第一个t表示tiny, turbo, 或throttling 与lighttpd.mem ...
- Angular2-------Error: Unexpected value ‘undefined’ declared by the module ‘模块名
请检查[app.module.ts]文件中的[declarations]模块最后是否多了一个逗号 (完)
随机推荐
- HDU 5792 L - World is Exploding 。容斥原理 + 树状数组 + 离散化
题目,要求找出有多少对这样的东西,四个数,并且满足num[a]<num[b] &&num[c]>num[d] 要做这题,首先要懂得用树状数组,我设,下面的小于和大于都是严格 ...
- Flume NG部署
本次配置单节点的Flume NG 1.下载flume安装包 下载地址:(http://flume.apache.org/download.html) apache-flume-1.6.0-bin.ta ...
- nginx去掉url中的index.php
使用情境:我想输入www.abc.com/a/1后,实际上是跳转到www.abc.com/index.php/a/1 配置Nginx.conf在你的虚拟主机下添加: location / { ...
- net start命令发生系统错误5和错误1058的解决方法
net start命令用于开启服务,格式为:net start [服务名](与之对应的"net stop [服务名]"为关闭服务命令) 5是没有管理员权限,右键管理员即可 1058 ...
- Java排序算法(三)
Java排序算法(三) 三.Java排序算法总结 从这三组时间复杂度对比中,可以看出,堆排序和归并排序是不管在什么情况下发挥稳定的,快速排序好的时候表现如天才,坏情况下比较差强人意,甚至在等待排序个数 ...
- 如何 求Ifeature 的面积
IArea pArea = pfteature_Source.Shape as IArea;// IArea来自geometry double dArea = Math.Round(pArea.Ar ...
- C#中常用的字符串验证
using System; using System.Text.RegularExpressions; namespace Util { public static class @string { # ...
- OC与JS交互前言
OC与JS交互过程中,可能会需要使用本地image资源及html,css,js文件,这些资源应该如何被加载? 一.WebView加载HTML UIWebView提供了三个方法来加载html资源 1. ...
- webpake-node-sass 报错
问题描述: npm run dev 就报错,在安装node-sass错误 解决方法 : 找到node_modules下的node-sass文件,进入,如果没有vendor文件夹,就创建一个空文件夹,命 ...
- 解决移动端浏览器页面 X轴横向滚动条问题
写web端页面的时候,总是会出现横向滚动条,即 X 轴滚动条,导致页面左右滑来滑去. 即使设置了 body,html {overflow-x:hidden;width:100%;} 也无法生效. 解决 ...