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-2010 Zend Technologies USA Inc. (http://www.zend.com)
20 * @license http://framework.zend.com/license/new-bsd New BSD License
25 * @see Zend_Gdata_Extension
27 require_once 'Zend/Gdata/Extension.php';
30 * @see Zend_Gdata_Gapps
32 require_once 'Zend/Gdata/Gapps.php';
35 * Represents the apps:Property element used by the Apps data API.
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_Gapps_Extension_Property extends Zend_Gdata_Extension
46 protected $_rootNamespace = 'apps';
47 protected $_rootElement = 'property';
50 * The name of the property
54 protected $_name = null;
57 * The value of the property
60 protected $_value = null;
63 * Constructs a new Zend_Gdata_Gapps_Extension_Property object.
65 * @param string $name The name of the property
66 * @param string $value The value of the property
68 public function __construct($name = null, $value = null)
70 $this->registerAllNamespaces(Zend_Gdata_Gapps::$namespaces);
71 parent::__construct();
73 $this->_value = $value;
79 * Retrieves a DOMElement which corresponds to this element and all
80 * child properties. This is used to build an entry back into a DOM
81 * and eventually XML text for sending to the server upon updates, or
82 * for application storage/persistence.
84 * @param DOMDocument $doc The DOMDocument used to construct DOMElements
85 * @return DOMElement The DOMElement representing this element and all
88 public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
90 $element = parent::getDOM($doc, $majorVersion, $minorVersion);
91 if ($this->_name !== null) {
92 $element->setAttribute('name', $this->_name);
94 if ($this->_value !== null) {
95 $element->setAttribute('value', $this->_value);
103 * Given a DOMNode representing an attribute, tries to map the data into
104 * instance members. If no mapping is defined, the name and value are
105 * stored in an array.
107 * @param DOMNode $attribute The DOMNode attribute needed to be handled
109 protected function takeAttributeFromDOM($attribute)
111 switch ($attribute->localName) {
113 $this->_name = $attribute->nodeValue;
116 $this->_value = $attribute->nodeValue;
119 parent::takeAttributeFromDOM($attribute);
124 * Get the value for this element's name attribute.
127 * @return string The requested attribute.
129 public function getName()
135 * Set the value for this element's name attribute.
136 * @param string $value The desired value for this attribute.
137 * @return Zend_Gdata_Gapps_Extension_Property The element being modified.
139 public function setName($value)
141 $this->_name = $value;
146 * Get the value for this element's value attribute.
149 * @return string The requested attribute.
151 public function getValue()
153 return $this->_value;
157 * Set the value for this element's value attribute.
159 * @param string $value The desired value for this attribute.
160 * @return Zend_Gdata_Gapps_Extension_Property The element being modified.
162 public function setValue($value)
164 $this->_value = $value;
169 * Magic toString method allows using this directly via echo
170 * Works best in PHP >= 4.2.0
174 public function __toString()
176 return "Property Name: " . $this->getName() .
177 "\nProperty Value: " . $this->getValue();