File indexing completed on 2024-12-29 05:28:08

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_Tool
0017  * @subpackage Framework
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_Tool_Framework_Action_Interface
0025  */
0026 // require_once 'Zend/Tool/Framework/Action/Interface.php';
0027 
0028 /**
0029  * @category   Zend
0030  * @package    Zend_Tool
0031  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0032  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0033  */
0034 class Zend_Tool_Framework_Action_Base implements Zend_Tool_Framework_Action_Interface
0035 {
0036 
0037     /**
0038      * @var string
0039      */
0040     protected $_name = null;
0041 
0042     /**
0043      * constructor -
0044      *
0045      * @param unknown_type $options
0046      */
0047     public function __construct($options = null)
0048     {
0049         if ($options !== null) {
0050             if (is_string($options)) {
0051                 $this->setName($options);
0052             }
0053             // implement $options here in the future if this is needed
0054         }
0055     }
0056 
0057     /**
0058      * setName()
0059      *
0060      * @param string $name
0061      * @return Zend_Tool_Framework_Action_Base
0062      */
0063     public function setName($name)
0064     {
0065         $this->_name = $name;
0066         return $this;
0067     }
0068 
0069     /**
0070      * getName()
0071      *
0072      * @return string
0073      */
0074     public function getName()
0075     {
0076         if ($this->_name == null) {
0077             $this->_name = $this->_parseName();
0078         }
0079         return $this->_name;
0080     }
0081 
0082     /**
0083      * _parseName - internal method to determine the name of an action when one is not explicity provided.
0084      *
0085      * @param Zend_Tool_Framework_Action_Interface $action
0086      * @return string
0087      */
0088     protected function _parseName()
0089     {
0090         $className = get_class($this);
0091         $actionName = substr($className, strrpos($className, '_')+1);
0092         return $actionName;
0093     }
0094 
0095 }