File indexing completed on 2025-01-26 05:24:53

0001 <?php
0002 /**
0003  * Zend Framework
0004  *
0005  * LICENSE
0006  *
0007  * This source file is subject to the new BSD license that is bundled
0008  * with this package in the file LICENSE.txt.
0009  * It is also available through the world-wide-web at this URL:
0010  * http://framework.zend.com/license/new-bsd
0011  * If you did not receive a copy of the license and are unable to
0012  * obtain it through the world-wide-web, please send an email
0013  * to license@zend.com so we can send you a copy immediately.
0014  *
0015  * @category   Zend
0016  * @package    Zend_Controller
0017  * @subpackage Zend_Controller_Action_Helper
0018  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0019  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0020  * @version    $Id$
0021  */
0022 
0023 /**
0024  * @see Zend_Controller_Action
0025  */
0026 // require_once 'Zend/Controller/Action.php';
0027 
0028 /**
0029  * @category   Zend
0030  * @package    Zend_Controller
0031  * @subpackage Zend_Controller_Action_Helper
0032  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0033  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0034  */
0035 abstract class Zend_Controller_Action_Helper_Abstract
0036 {
0037     /**
0038      * $_actionController
0039      *
0040      * @var Zend_Controller_Action $_actionController
0041      */
0042     protected $_actionController = null;
0043 
0044     /**
0045      * @var mixed $_frontController
0046      */
0047     protected $_frontController = null;
0048 
0049     /**
0050      * setActionController()
0051      *
0052      * @param  Zend_Controller_Action $actionController
0053      * @return Zend_Controller_ActionHelper_Abstract Provides a fluent interface
0054      */
0055     public function setActionController(Zend_Controller_Action $actionController = null)
0056     {
0057         $this->_actionController = $actionController;
0058         return $this;
0059     }
0060 
0061     /**
0062      * Retrieve current action controller
0063      *
0064      * @return Zend_Controller_Action
0065      */
0066     public function getActionController()
0067     {
0068         return $this->_actionController;
0069     }
0070 
0071     /**
0072      * Retrieve front controller instance
0073      *
0074      * @return Zend_Controller_Front
0075      */
0076     public function getFrontController()
0077     {
0078         return Zend_Controller_Front::getInstance();
0079     }
0080 
0081     /**
0082      * Hook into action controller initialization
0083      *
0084      * @return void
0085      */
0086     public function init()
0087     {
0088     }
0089 
0090     /**
0091      * Hook into action controller preDispatch() workflow
0092      *
0093      * @return void
0094      */
0095     public function preDispatch()
0096     {
0097     }
0098 
0099     /**
0100      * Hook into action controller postDispatch() workflow
0101      *
0102      * @return void
0103      */
0104     public function postDispatch()
0105     {
0106     }
0107 
0108     /**
0109      * getRequest() -
0110      *
0111      * @return Zend_Controller_Request_Abstract $request
0112      */
0113     public function getRequest()
0114     {
0115         $controller = $this->getActionController();
0116         if (null === $controller) {
0117             $controller = $this->getFrontController();
0118         }
0119 
0120         return $controller->getRequest();
0121     }
0122 
0123     /**
0124      * getResponse() -
0125      *
0126      * @return Zend_Controller_Response_Abstract $response
0127      */
0128     public function getResponse()
0129     {
0130         $controller = $this->getActionController();
0131         if (null === $controller) {
0132             $controller = $this->getFrontController();
0133         }
0134 
0135         return $controller->getResponse();
0136     }
0137 
0138     /**
0139      * getName()
0140      *
0141      * @return string
0142      */
0143     public function getName()
0144     {
0145         $fullClassName = get_class($this);
0146         if (strpos($fullClassName, '_') !== false) {
0147             $helperName = strrchr($fullClassName, '_');
0148             return ltrim($helperName, '_');
0149         } elseif (strpos($fullClassName, '\\') !== false) {
0150             $helperName = strrchr($fullClassName, '\\');
0151             return ltrim($helperName, '\\');
0152         } else {
0153             return $fullClassName;
0154         }
0155     }
0156 }