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

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