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.
18 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
19 * @license http://framework.zend.com/license/new-bsd New BSD License
24 * @see Zend_Gdata_App_Extension_Control
26 require_once 'Zend/Gdata/App/Extension/Control.php';
29 * @see Zend_Gdata_YouTube_Extension_State
31 require_once 'Zend/Gdata/YouTube/Extension/State.php';
35 * Specialized Control class for use with YouTube. Enables use of yt extension elements.
40 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
41 * @license http://framework.zend.com/license/new-bsd New BSD License
43 class Zend_Gdata_YouTube_Extension_Control extends Zend_Gdata_App_Extension_Control
46 protected $_state = null;
49 * Constructs a new Zend_Gdata_Calendar_Extension_Control object.
50 * @see Zend_Gdata_App_Extension_Control#__construct
51 * @param Zend_Gdata_App_Extension_Draft $draft
52 * @param Zend_Gdata_YouTube_Extension_State $state
54 public function __construct($draft = null, $state = null)
56 $this->registerAllNamespaces(Zend_Gdata_YouTube::$namespaces);
57 parent::__construct($draft);
58 $this->_state = $state;
62 * Retrieves a DOMElement which corresponds to this element and all
63 * child properties. This is used to build an entry back into a DOM
64 * and eventually XML text for sending to the server upon updates, or
65 * for application storage/persistence.
67 * @param DOMDocument $doc The DOMDocument used to construct DOMElements
68 * @return DOMElement The DOMElement representing this element and all
71 public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
73 $element = parent::getDOM($doc, $majorVersion, $minorVersion);
74 if ($this->_state != null) {
75 $element->appendChild($this->_state->getDOM($element->ownerDocument));
81 * Creates individual Entry objects of the appropriate type and
82 * stores them as members of this entry based upon DOM data.
84 * @param DOMNode $child The DOMNode to process
86 protected function takeChildFromDOM($child)
88 $absoluteNodeName = $child->namespaceURI . ':' . $child->localName;
89 switch ($absoluteNodeName) {
90 case $this->lookupNamespace('yt') . ':' . 'state':
91 $state = new Zend_Gdata_YouTube_Extension_State();
92 $state->transferFromDOM($child);
93 $this->_state = $state;
96 parent::takeChildFromDOM($child);
102 * Get the value for this element's state attribute.
104 * @return Zend_Gdata_YouTube_Extension_State The state element.
106 public function getState()
108 return $this->_state;
112 * Set the value for this element's state attribute.
114 * @param Zend_Gdata_YouTube_Extension_State $value The desired value for this attribute.
115 * @return Zend_YouTube_Extension_Control The element being modified.
117 public function setState($value)
119 $this->_state = $value;
124 * Get the value of this element's state attribute.
126 * @return string The state's text value
128 public function getStateValue()
130 return $this->getState()->getText();