Zend_Controller 插件编写
来源:互联网 发布:淘宝买家聊天工具 编辑:程序博客网 时间:2024/04/27 13:13
Zend_Controller_Plugin_Abstract 是一个专门用于插件编写的抽象类,动手术之前肯定要分析的类的源码,Zend framework在某种程度上说慢,一部分也是由于includet的文件实在过于复杂累赘,启动mvc那么此文件已经载入系统,为您和您的家人提供方便,呵呵~
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Controller
* @subpackage Plugins
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_Controller_Request_Abstract */
require_once 'Zend/Controller/Request/Abstract.php';
/** Zend_Controller_Response_Abstract */
require_once 'Zend/Controller/Response/Abstract.php';
/**
* @category Zend
* @package Zend_Controller
* @subpackage Plugins
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
abstract class Zend_Controller_Plugin_Abstract
{
/**
* @var Zend_Controller_Request_Abstract
*/
protected $_request;
/**
* @var Zend_Controller_Response_Abstract
*/
protected $_response;
/**
* Set request object
*
* @param Zend_Controller_Request_Abstract $request
* @return Zend_Controller_Plugin_Abstract
*/
public function setRequest(Zend_Controller_Request_Abstract $request)
{
$this->_request = $request;
return $this;
}
/**
* Get request object
*
* @return Zend_Controller_Request_Abstract $request
*/
public function getRequest()
{
return $this->_request;
}
/**
* Set response object
*
* @param Zend_Controller_Response_Abstract $response
* @return Zend_Controller_Plugin_Abstract
*/
public function setResponse(Zend_Controller_Response_Abstract $response)
{
$this->_response = $response;
return $this;
}
/**
* Get response object
*
* @return Zend_Controller_Response_Abstract $response
*/
public function getResponse()
{
return $this->_response;
}
/**
* Called before Zend_Controller_Front begins evaluating the
* request against its routes.
*
* @param Zend_Controller_Request_Abstract $request
* @return void
*/
public function routeStartup(Zend_Controller_Request_Abstract $request)
{}
/**
* Called after Zend_Controller_Router exits.
*
* Called after Zend_Controller_Front exits from the router.
*
* @param Zend_Controller_Request_Abstract $request
* @return void
*/
public function routeShutdown(Zend_Controller_Request_Abstract $request)
{}
/**
* Called before Zend_Controller_Front enters its dispatch loop.
*
* @param Zend_Controller_Request_Abstract $request
* @return void
*/
public function dispatchLoopStartup(Zend_Controller_Request_Abstract $request)
{}
/**
* Called before an action is dispatched by Zend_Controller_Dispatcher.
*
* This callback allows for proxy or filter behavior. By altering the
* request and resetting its dispatched flag (via
* {@link Zend_Controller_Request_Abstract::setDispatched() setDispatched(false)}),
* the current action may be skipped.
*
* @param Zend_Controller_Request_Abstract $request
* @return void
*/
public function preDispatch(Zend_Controller_Request_Abstract $request)
{}
/**
* Called after an action is dispatched by Zend_Controller_Dispatcher.
*
* This callback allows for proxy or filter behavior. By altering the
* request and resetting its dispatched flag (via
* {@link Zend_Controller_Request_Abstract::setDispatched() setDispatched(false)}),
* a new action may be specified for dispatching.
*
* @param Zend_Controller_Request_Abstract $request
* @return void
*/
public function postDispatch(Zend_Controller_Request_Abstract $request)
{}
/**
* Called before Zend_Controller_Front exits its dispatch loop.
*
* @return void
*/
public function dispatchLoopShutdown()
{}
}
我们所做的工作就是将其重载
class MyPlugin extends Zend_Controller_Plugin_Abstract
{
public function routeStartup(Zend_Controller_Request_Abstract $request)
{
$this->getResponse()->appendBody("<p>routeStartup() called</p>/n");
}
public function routeShutdown(Zend_Controller_Request_Abstract $request)
{
$this->getResponse()->appendBody("<p>routeShutdown() called</p>/n");
}
public function dispatchLoopStartup(Zend_Controller_Request_Abstract $request)
{
$this->getResponse()->appendBody("<p>dispatchLoopStartup() called</p>/n");
}
public function preDispatch(Zend_Controller_Request_Abstract $request)
{
$this->getResponse()->appendBody("<p>preDispatch() called</p>/n");
}
public function postDispatch(Zend_Controller_Request_Abstract $request)
{
$this->getResponse()->appendBody("<p>postDispatch() called</p>/n");
}
public function dispatchLoopShutdown()
{
$this->getResponse()->appendBody("<p>dispatchLoopShutdown() called</p>/n");
}
}
建议其插件的使用是其后期补救的一种手段而已
- Zend_Controller 插件编写
- 16. Zend_Controller
- 插件编写
- 插件编写
- Zend Framework-Zend_Controller入门
- Zend_Controller 快速入门
- Zend Framework教程-Zend_Controller
- 2. Zend_Controller 快速入门
- 2.2 Zend_Controller 基础
- Zend_Controller Quick Start
- 【1】Golismero插件编写-UI插件编写
- 【2】Golismero插件编写-TestingPlugin插件编写
- 【3】Golismero插件编写-ImportPlugin插件编写
- jQuery插件 - 编写基本插件
- 7.1 编写插件-插件101
- 7.2 编写插件-模型插件
- 7.3 编写插件-世界插件
- 7.5 编写插件-系统插件
- eclipse使用总结
- C#实现带指定文本水印的截图(指定窗口与 全屏)
- HTML的xmlns 属性
- 工薪族创业
- 数据库设计方法学总结
- Zend_Controller 插件编写
- WYTC-C#-控制項ListView(列舉檢視)
- Zend_Controller_Router_Route_Static引擎的使用
- 调试php的代码
- linux下设置vga显示模式方法
- fso
- php多线程sqlite的单线程
- 多线程编程的溢出
- 使用php发送msn消息