PageRenderTime 29ms CodeModel.GetById 27ms app.highlight 1ms RepoModel.GetById 0ms app.codeStats 0ms

/zf/library/Zend/Controller/Action/Helper/Abstract.php

http://github.com/eryx/php-framework-benchmark
PHP | 156 lines | 58 code | 14 blank | 84 comment | 3 complexity | 5cdc773cdd5dba6fb5ae8575506f29e1 MD5 | raw file
Possible License(s): MIT, BSD-3-Clause, Apache-2.0, LGPL-2.1, LGPL-3.0, BSD-2-Clause
  1<?php
  2/**
  3 * Zend Framework
  4 *
  5 * LICENSE
  6 *
  7 * This source file is subject to the new BSD license that is bundled
  8 * with this package in the file LICENSE.txt.
  9 * It is also available through the world-wide-web at this URL:
 10 * http://framework.zend.com/license/new-bsd
 11 * If you did not receive a copy of the license and are unable to
 12 * obtain it through the world-wide-web, please send an email
 13 * to license@zend.com so we can send you a copy immediately.
 14 *
 15 * @category   Zend
 16 * @package    Zend_Controller
 17 * @subpackage Zend_Controller_Action_Helper
 18 * @copyright  Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
 19 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 20 * @version    $Id: Abstract.php 23775 2011-03-01 17:25:24Z ralph $
 21 */
 22
 23/**
 24 * @see Zend_Controller_Action
 25 */
 26require_once 'Zend/Controller/Action.php';
 27
 28/**
 29 * @category   Zend
 30 * @package    Zend_Controller
 31 * @subpackage Zend_Controller_Action_Helper
 32 * @copyright  Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
 33 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 34 */
 35abstract class Zend_Controller_Action_Helper_Abstract
 36{
 37    /**
 38     * $_actionController
 39     *
 40     * @var Zend_Controller_Action $_actionController
 41     */
 42    protected $_actionController = null;
 43
 44    /**
 45     * @var mixed $_frontController
 46     */
 47    protected $_frontController = null;
 48
 49    /**
 50     * setActionController()
 51     *
 52     * @param  Zend_Controller_Action $actionController
 53     * @return Zend_Controller_ActionHelper_Abstract Provides a fluent interface
 54     */
 55    public function setActionController(Zend_Controller_Action $actionController = null)
 56    {
 57        $this->_actionController = $actionController;
 58        return $this;
 59    }
 60
 61    /**
 62     * Retrieve current action controller
 63     *
 64     * @return Zend_Controller_Action
 65     */
 66    public function getActionController()
 67    {
 68        return $this->_actionController;
 69    }
 70
 71    /**
 72     * Retrieve front controller instance
 73     *
 74     * @return Zend_Controller_Front
 75     */
 76    public function getFrontController()
 77    {
 78        return Zend_Controller_Front::getInstance();
 79    }
 80
 81    /**
 82     * Hook into action controller initialization
 83     *
 84     * @return void
 85     */
 86    public function init()
 87    {
 88    }
 89
 90    /**
 91     * Hook into action controller preDispatch() workflow
 92     *
 93     * @return void
 94     */
 95    public function preDispatch()
 96    {
 97    }
 98
 99    /**
100     * Hook into action controller postDispatch() workflow
101     *
102     * @return void
103     */
104    public function postDispatch()
105    {
106    }
107
108    /**
109     * getRequest() -
110     *
111     * @return Zend_Controller_Request_Abstract $request
112     */
113    public function getRequest()
114    {
115        $controller = $this->getActionController();
116        if (null === $controller) {
117            $controller = $this->getFrontController();
118        }
119
120        return $controller->getRequest();
121    }
122
123    /**
124     * getResponse() -
125     *
126     * @return Zend_Controller_Response_Abstract $response
127     */
128    public function getResponse()
129    {
130        $controller = $this->getActionController();
131        if (null === $controller) {
132            $controller = $this->getFrontController();
133        }
134
135        return $controller->getResponse();
136    }
137
138    /**
139     * getName()
140     *
141     * @return string
142     */
143    public function getName()
144    {
145        $fullClassName = get_class($this);
146        if (strpos($fullClassName, '_') !== false) {
147            $helperName = strrchr($fullClassName, '_');
148            return ltrim($helperName, '_');
149        } elseif (strpos($fullClassName, '\\') !== false) {
150            $helperName = strrchr($fullClassName, '\\');
151            return ltrim($helperName, '\\');
152        } else {
153            return $fullClassName;
154        }
155    }
156}