<?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 - 模块入口文件的更多相关文章

  1. DISCUZ论坛各大功能模块入口文件介绍

    index.php 首页入口文件,这个文件相信大家都不陌生,小编就不具体介绍了. forum.php 论坛入口文件 portal.php 门户入口文件 group.php 群组入口文件 home.ph ...

  2. webpack 配置多入口文件,输出多出口文件

    const path = require('path') module.exports = { // 入口文件的配置项 entry: { // 入口文件 entry: './src/entry.js' ...

  3. thinkphp 的两种建构模式 第一种一个单入口里面定义两个模块,前台和后台,函数控制模块必须function.php前台加载前台模块的汉书配置文件,后台加载后台模块的汉书配置文件,公共文件共用。第二种架构模式两个单入口文件,分别生成两个应用定义define。。。函数可以定义配置文件。。。。

    thinkphp 的两种建构模式  第一种一个单入口里面定义两个模块,前台和后台,函数控制模块必须function.php前台加载前台模块的汉书配置文件,后台加载后台模块的汉书配置文件,公共文件共用. ...

  4. Ubuntu Server 14.04 & Apache2.4 虚拟主机、模块重写、隐藏入口文件配置

    环境: Ubuntu Server 14.04 , Apache2.4 一.Apache2.4 虚拟主机配置 01. 新建一份配置文件 在apache2.4中,虚拟主机的目录是通过/etc/apach ...

  5. thinkphp3.2后台模块怎么添加(admin),直接复制Home?还是在入口文件生成?

    1.都可以,复制home改下命名空间也行,在入口添加下参数自动生成也行 2ThinkPHP3.2后支持模块化开发,在Home目录的同级目录下创建一个新的文件夹,命名为Admin,或者就如你自己所说,直 ...

  6. JavaScript ES6 module 模块

    在使用JavaScript开发大型项目时,模块开发概念是一个必须考虑的问题.其目的就是通过命名空间对各类业务对象进行一定的封装,防止命名冲突. 本篇着重介绍ES6 module中的export和imp ...

  7. 利用Module模块把构建的神经网络跑起来

    训练一个神经网络往往只需要简单的几步: 准备训练数据 初始化模型的参数 模型向往计算与向后计算 更新模型参数 设置相关的checkpoint 如果上述的每个步骤都需要我们写Python的代码去一步步实 ...

  8. thttpd源代码解析 定时器模块

    thttpd源代码解析 定时器模块 thttpd是很轻量级的httpserver,可运行文件仅50kB.名称中的第一个t表示tiny, turbo, 或throttling 与lighttpd.mem ...

  9. Angular2-------Error: Unexpected value ‘undefined’ declared by the module ‘模块名

    请检查[app.module.ts]文件中的[declarations]模块最后是否多了一个逗号 (完)

随机推荐

  1. (转)linux配置网卡的命令

    linux配置网卡的命令 原文:http://blog.51cto.com/lanxianting/1754923 1.配置命令 如果一台服务器需要通外网,能被远程连接,就得给这个台服务器配置ip,子 ...

  2. 合理设置apache httpd的最大连接数--linux

    手头有一个网站在线人数增多,访问时很慢.初步认为是服务器资源不足了,但经反复测试,一旦连接上,不断点击同一个页面上不同的链接,都能迅速打开,这种现象就是说明apache最大连接数已经满了,新的访客只能 ...

  3. 性能测试学习第四天_Loadrunner概述

    1.Loadrunner的组成部分 ·脚本生成器VuGen:virtual user generator ·压力控制器Controller,License主要在这里控制 ·结果分析软件Analysis ...

  4. 从零开始的全栈工程师——js篇2.2

    条件语句 补充: var a=“hello world” a这个变量是字符串了 对于里面每一个字母来说 他是字节 里面有11个字节 字节总数用length表示 如下: 根据上面的内容咱们又发现了一个运 ...

  5. python随笔---录入月份的值,输出对应的季节

    首先获取一个输入,加判断,输入对应的月份,季节判定根据气象划分法(气象划分法:在气象部门,通常以阳历3-5月为春季,6-8月为夏季,9-11月为秋季,12月-来年2月为冬季,并且常常把1.4.7.10 ...

  6. 【干货】Html与CSS入门学习笔记1-3

    从23号开始用了4天时间看完了<Head First Html与CSS>这本书,本书讲解方式深入浅出,便于理解,结合习题,便于记忆,是一本不错的入门书.下面是本书的学习笔记: 一.认识HT ...

  7. python super用法

    普通继承 class FooParent(object): def __init__(self): self.parent = 'I\'m the parent.' print 'Parent' de ...

  8. SQL 语句 使用附加和分离

    use mastergo declare @flg int --返回0表示成功 否则表示失败declare @msg varchar(50) --显示成功或失败的消息declare @dbname v ...

  9. 怎么旋转PDF文件的方向并保存成功

    http://jingyan.baidu.com/article/59a015e39d7802f79488651e.html PDF格式的文档是非常普遍的一种阅读电子书格式,基本上非常好用了,不过有时 ...

  10. VS打包方法(安装和部署简介)——内含大量图片,密症慎入!

    友情提示:内含大量文字.图片,密集恐惧症者慎入! 主要记述一下利用微软集成开发环境VS打包的方法和详细步骤. 1.新建打包工程 打开VS,文件->添加项目->新建项目(如图1),在添加新项 ...