<?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. volatile底层原理详解

    今天我们聊聊volatile底层原理: Java语言规范对于volatile定义如下: Java编程语言允许线程访问共享变量,为了确保共享变量能够被准确和一致性地更新,线程应该确保通过排它锁单独获得这 ...

  2. HDU 5452——Minimum Cut——————【树链剖分+差分前缀和】ACdream 1429——Diversion——————【树链剖分】

    Minimum Cut Time Limit: 3000/2000 MS (Java/Others)    Memory Limit: 65535/102400 K (Java/Others)Tota ...

  3. BZOJ3624: [Apio2008]免费道路(最小生成树)

    题意 题目链接 Sol 首先答案一定是一棵树 这棵树上有一些0边是必须要选的,我们先把他们找出来,如果数量$\geqslant k$显然无解 再考虑继续往里面加0的边,判断能否加到k条即可 具体做法是 ...

  4. Java图形界面开发—简易登录注册小程序

    登录注册小代码,将学过的一些小知识融合在一起进行了使用,加深印象.本例中如果有注释不详细的地方,详见其它博客. Java程序操作数据库SQLserver详解 功能介绍:简单的登录注册系统,使用了数据库 ...

  5. wechat开发笔记之1.接口示例代码

    修改后的php示例代码! <?php /** * wechat php test */ //define your token define("TOKEN", "w ...

  6. jquery mmgrid使用

    参考 http://miemiedev.github.io/mmGrid/examples/index.html

  7. springMvc-框架搭建

    搭建springmvc框架的步骤: 1.在web.xml中配置springMvc的servlet 2.创建controller处理页面传来的数据, 3.床架springMvc文件,处理视图: 3.1: ...

  8. LeetCode Length of Last Word 最后一个字的长度

    class Solution { public: int lengthOfLastWord(const char *s) { ; string snew=s; ,len=strlen(s); ]; ) ...

  9. 利用jsplumb和碰撞检测自动生成流程图

    使用jsplumb构建流程图模型时,有一个需求要求,选项可以从选项表中拖拽到指定容器,并且两个选项要接触到的时候才能连接起来,不接触不能连接.效果图如下 略丑- 因为这里用到了拖拽,拖放功能,所以用到 ...

  10. CentOs7 修复 引导启动

    一.修复MBR: MBR(Master Boot Record主引导记录): 硬盘的0柱面.0磁头.1扇区称为主引导扇区.其中446Byte是bootloader,64Byte为Partition t ...