PageRenderTime 39ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 0ms

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

https://github.com/chasemaier/zf1
PHP | 156 lines | 58 code | 14 blank | 84 comment | 3 complexity | 5d19ab28ef66e46d6e0bb8617e966af4 MD5 | raw file
Possible License(s): BSD-3-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-2014 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. * @version $Id$
  21. */
  22. /**
  23. * @see Zend_Controller_Action
  24. */
  25. require_once 'Zend/Controller/Action.php';
  26. /**
  27. * @category Zend
  28. * @package Zend_Controller
  29. * @subpackage Zend_Controller_Action_Helper
  30. * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
  31. * @license http://framework.zend.com/license/new-bsd New BSD License
  32. */
  33. abstract class Zend_Controller_Action_Helper_Abstract
  34. {
  35. /**
  36. * $_actionController
  37. *
  38. * @var Zend_Controller_Action $_actionController
  39. */
  40. protected $_actionController = null;
  41. /**
  42. * @var mixed $_frontController
  43. */
  44. protected $_frontController = null;
  45. /**
  46. * setActionController()
  47. *
  48. * @param Zend_Controller_Action $actionController
  49. * @return Zend_Controller_ActionHelper_Abstract Provides a fluent interface
  50. */
  51. public function setActionController(Zend_Controller_Action $actionController = null)
  52. {
  53. $this->_actionController = $actionController;
  54. return $this;
  55. }
  56. /**
  57. * Retrieve current action controller
  58. *
  59. * @return Zend_Controller_Action
  60. */
  61. public function getActionController()
  62. {
  63. return $this->_actionController;
  64. }
  65. /**
  66. * Retrieve front controller instance
  67. *
  68. * @return Zend_Controller_Front
  69. */
  70. public function getFrontController()
  71. {
  72. return Zend_Controller_Front::getInstance();
  73. }
  74. /**
  75. * Hook into action controller initialization
  76. *
  77. * @return void
  78. */
  79. public function init()
  80. {
  81. }
  82. /**
  83. * Hook into action controller preDispatch() workflow
  84. *
  85. * @return void
  86. */
  87. public function preDispatch()
  88. {
  89. }
  90. /**
  91. * Hook into action controller postDispatch() workflow
  92. *
  93. * @return void
  94. */
  95. public function postDispatch()
  96. {
  97. }
  98. /**
  99. * getRequest() -
  100. *
  101. * @return Zend_Controller_Request_Abstract $request
  102. */
  103. public function getRequest()
  104. {
  105. $controller = $this->getActionController();
  106. if (null === $controller) {
  107. $controller = $this->getFrontController();
  108. }
  109. return $controller->getRequest();
  110. }
  111. /**
  112. * getResponse() -
  113. *
  114. * @return Zend_Controller_Response_Abstract $response
  115. */
  116. public function getResponse()
  117. {
  118. $controller = $this->getActionController();
  119. if (null === $controller) {
  120. $controller = $this->getFrontController();
  121. }
  122. return $controller->getResponse();
  123. }
  124. /**
  125. * getName()
  126. *
  127. * @return string
  128. */
  129. public function getName()
  130. {
  131. $fullClassName = get_class($this);
  132. if (strpos($fullClassName, '_') !== false) {
  133. $helperName = strrchr($fullClassName, '_');
  134. return ltrim($helperName, '_');
  135. } elseif (strpos($fullClassName, '\\') !== false) {
  136. $helperName = strrchr($fullClassName, '\\');
  137. return ltrim($helperName, '\\');
  138. } else {
  139. return $fullClassName;
  140. }
  141. }
  142. }