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]模块最后是否多了一个逗号 (完)
随机推荐
- 029 Divide Two Integers 两数相除
不使用乘号,除号和取模符号将两数相除.如果溢出返回 MAX_INT.详见:https://leetcode.com/problems/divide-two-integers/description/ ...
- PullToRefreshListView
@Override protected void onRefreshing(final boolean doScroll) { /** * If we're not showing the Refre ...
- Fence Repair (二叉树求解)(优先队列,先取出小的)
题目链接:http://poj.org/problem?id=3253 Fence Repair Time Limit: 2000MS Memory Limit: 65536K Total Sub ...
- kolla-ansible-----rally模块
Rally简介 Rally是OpenStack社区推出开源测试工具,可用于对OpenStack各个组件进行性能测试. 通过使用Rally组件,用户可完成OpenStack云计算平台的安装部署.功能验证 ...
- 深入理解C#中的IDisposable接口(转)
转自:https://www.cnblogs.com/wyt007/p/9304564.html 写在前面 在开始之前,我们需要明确什么是C#(或者说.NET)中的资源,打码的时候我们经常说释放资源, ...
- 一般的linux系统默认安装的vim是精简版
一般的linux系统默认安装的vim是精简版(vim-tiny),所以不能配置语法检查等属性或获取在线帮助.需要安装vim-x:x.x.x,vim-common,vim-runtime. :synta ...
- linux系统redis配置环境变量
1.测试:在任何位置登录redis redis-cli 指定服务器ip(不指定时,默认本机) redis-cli -h 127.0.0.1 指定端口(不指定时,默认6379) redis-cli -h ...
- 安装xenserver过程中出现的问题
运行环境:win10系统,神舟战神z7m-KP7GT型号笔记本,VMWare虚拟机,XenServer7.2.0,XenCenter7.2.0 5月22日下午安装上xenserver虚拟机,发现虚拟机 ...
- 韦东山笔记之用busybox构建根文件系统
1 百度搜索busybox进入busybox官网(https://busybox.net/)作者:恒久力行 QQ:624668529 点击左侧DownloadSource下载最新稳定版的busybo ...
- String对象中常用的方法有哪些?
1.length()字符串长度 String str="abc"; System.out.println(str.length()); //输出3 2.charAt()截取一个字符 ...