8 * This source file is subject to the new BSD license that is bundled
9 * with this package in the file LICENSE.txt.
10 * It is also available through the world-wide-web at this URL:
11 * http://framework.zend.com/license/new-bsd
12 * If you did not receive a copy of the license and are unable to
13 * obtain it through the world-wide-web, please send an email
14 * to license@zend.com so we can send you a copy immediately.
19 * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
20 * @license http://framework.zend.com/license/new-bsd New BSD License
21 * @version $Id: State.php 16971 2009-07-22 18:05:45Z mikaelkael $
25 * @see Zend_Gdata_Extension
27 require_once 'Zend/Gdata/Extension.php';
30 * Represents the yt:state element used by the YouTube data API
35 * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
36 * @license http://framework.zend.com/license/new-bsd New BSD License
38 class Zend_Gdata_YouTube_Extension_State
extends Zend_Gdata_Extension
41 protected $_rootNamespace = 'yt';
42 protected $_rootElement = 'state';
43 protected $_name = null;
44 protected $_reasonCode = null;
45 protected $_helpUrl = null;
48 * Constructs a new Zend_Gdata_YouTube_Extension_State object.
50 * @param string $explanation(optional) The explanation of this state
51 * @param string $name(optional) The name value
52 * @param string $reasonCode(optional) The reasonCode value
53 * @param string $helpUrl(optional) The helpUrl value
55 public function __construct($explanation = null, $name = null,
56 $reasonCode = null, $helpUrl = null)
58 $this->registerAllNamespaces(Zend_Gdata_YouTube
::$namespaces);
59 parent
::__construct();
60 $this->_text
= $explanation;
62 $this->_reasonCode
= $reasonCode;
63 $this->_helpUrl
= $reasonCode;
67 * Retrieves a DOMElement which corresponds to this element and all
68 * child properties. This is used to build an entry back into a DOM
69 * and eventually XML text for sending to the server upon updates, or
70 * for application storage/persistence.
72 * @param DOMDocument $doc The DOMDocument used to construct DOMElements
73 * @return DOMElement The DOMElement representing this element and all
76 public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
78 $element = parent
::getDOM($doc, $majorVersion, $minorVersion);
79 if ($this->_name
!== null) {
80 $element->setAttribute('name', $this->_name
);
82 if ($this->_reasonCode
!== null) {
83 $element->setAttribute('reasonCode', $this->_reasonCode
);
85 if ($this->_helpUrl
!== null) {
86 $element->setAttribute('helpUrl', $this->_helpUrl
);
92 * Given a DOMNode representing an attribute, tries to map the data into
93 * instance members. If no mapping is defined, the name and valueare
95 * TODO: Convert attributes to proper types
97 * @param DOMNode $attribute The DOMNode attribute needed to be handled
99 protected function takeAttributeFromDOM($attribute)
101 switch ($attribute->localName
) {
103 $this->_name
= $attribute->nodeValue
;
106 $this->_reasonCode
= $attribute->nodeValue
;
109 $this->_helpUrl
= $attribute->nodeValue
;
112 parent
::takeAttributeFromDOM($attribute);
117 * Get the value for this element's name attribute.
119 * @return int The value associated with this attribute.
121 public function getName()
127 * Set the value for this element's name attribute.
129 * @param int $value The desired value for this attribute.
130 * @return Zend_Gdata_YouTube_Extension_State The element being modified.
132 public function setName($value)
134 $this->_name
= $value;
139 * Get the value for this element's reasonCode attribute.
141 * @return int The value associated with this attribute.
143 public function getReasonCode()
145 return $this->_reasonCode
;
149 * Set the value for this element's reasonCode attribute.
151 * @param int $value The desired value for this attribute.
152 * @return Zend_Gdata_YouTube_Extension_State The element being modified.
154 public function setReasonCode($value)
156 $this->_reasonCode
= $value;
161 * Get the value for this element's helpUrl attribute.
163 * @return int The value associated with this attribute.
165 public function getHelpUrl()
167 return $this->_helpUrl
;
171 * Set the value for this element's helpUrl attribute.
173 * @param int $value The desired value for this attribute.
174 * @return Zend_Gdata_YouTube_Extension_State The element being modified.
176 public function setHelpUrl($value)
178 $this->_helpUrl
= $value;
183 * Magic toString method allows using this directly via echo
184 * Works best in PHP >= 4.2.0
188 public function __toString()