/library/Zend/Tool/Framework/Action/Base.php

https://bitbucket.org/hamidrezas/melobit · PHP · 95 lines · 32 code · 8 blank · 55 comment · 4 complexity · 490a281e6fb1b61983abb33688b05111 MD5 · raw file

  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_Tool
  17. * @subpackage Framework
  18. * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. * @version $Id: Base.php 24594 2012-01-05 21:27:01Z matthew $
  21. */
  22. /**
  23. * @see Zend_Tool_Framework_Action_Interface
  24. */
  25. require_once 'Zend/Tool/Framework/Action/Interface.php';
  26. /**
  27. * @category Zend
  28. * @package Zend_Tool
  29. * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
  30. * @license http://framework.zend.com/license/new-bsd New BSD License
  31. */
  32. class Zend_Tool_Framework_Action_Base implements Zend_Tool_Framework_Action_Interface
  33. {
  34. /**
  35. * @var string
  36. */
  37. protected $_name = null;
  38. /**
  39. * constructor -
  40. *
  41. * @param unknown_type $options
  42. */
  43. public function __construct($options = null)
  44. {
  45. if ($options !== null) {
  46. if (is_string($options)) {
  47. $this->setName($options);
  48. }
  49. // implement $options here in the future if this is needed
  50. }
  51. }
  52. /**
  53. * setName()
  54. *
  55. * @param string $name
  56. * @return Zend_Tool_Framework_Action_Base
  57. */
  58. public function setName($name)
  59. {
  60. $this->_name = $name;
  61. return $this;
  62. }
  63. /**
  64. * getName()
  65. *
  66. * @return string
  67. */
  68. public function getName()
  69. {
  70. if ($this->_name == null) {
  71. $this->_name = $this->_parseName();
  72. }
  73. return $this->_name;
  74. }
  75. /**
  76. * _parseName - internal method to determine the name of an action when one is not explicity provided.
  77. *
  78. * @param Zend_Tool_Framework_Action_Interface $action
  79. * @return string
  80. */
  81. protected function _parseName()
  82. {
  83. $className = get_class($this);
  84. $actionName = substr($className, strrpos($className, '_')+1);
  85. return $actionName;
  86. }
  87. }