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:name element used by the Apps data API. This is used
36 * to represent a user's full name. This class is usually contained within
37 * instances of Zend_Gdata_Gapps_UserEntry.
42 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
43 * @license http://framework.zend.com/license/new-bsd New BSD License
45 class Zend_Gdata_Gapps_Extension_Name extends Zend_Gdata_Extension
48 protected $_rootNamespace = 'apps';
49 protected $_rootElement = 'name';
52 * The associated user's family name.
56 protected $_familyName = null;
59 * The associated user's given name.
63 protected $_givenName = null;
66 * Constructs a new Zend_Gdata_Gapps_Extension_Name object.
68 * @param string $familyName (optional) The familyName to be set for this
70 * @param string $givenName (optional) The givenName to be set for this
73 public function __construct($familyName = null, $givenName = null)
75 $this->registerAllNamespaces(Zend_Gdata_Gapps::$namespaces);
76 parent::__construct();
77 $this->_familyName = $familyName;
78 $this->_givenName = $givenName;
82 * Retrieves a DOMElement which corresponds to this element and all
83 * child properties. This is used to build an entry back into a DOM
84 * and eventually XML text for sending to the server upon updates, or
85 * for application storage/persistence.
87 * @param DOMDocument $doc The DOMDocument used to construct DOMElements
88 * @return DOMElement The DOMElement representing this element and all
91 public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
93 $element = parent::getDOM($doc, $majorVersion, $minorVersion);
94 if ($this->_familyName !== null) {
95 $element->setAttribute('familyName', $this->_familyName);
97 if ($this->_givenName !== null) {
98 $element->setAttribute('givenName', $this->_givenName);
104 * Given a DOMNode representing an attribute, tries to map the data into
105 * instance members. If no mapping is defined, the name and value are
106 * stored in an array.
108 * @param DOMNode $attribute The DOMNode attribute needed to be handled
110 protected function takeAttributeFromDOM($attribute)
112 switch ($attribute->localName) {
114 $this->_familyName = $attribute->nodeValue;
117 $this->_givenName = $attribute->nodeValue;
120 parent::takeAttributeFromDOM($attribute);
125 * Get the value for this element's familyName attribute.
128 * @return string The requested attribute.
130 public function getFamilyName()
132 return $this->_familyName;
136 * Set the value for this element's familyName attribute. This
137 * represents a user's family name.
139 * @param string $value The desired value for this attribute.
140 * @return Zend_Gdata_Gapps_Extension_Name Provides a fluent interface..
142 public function setFamilyName($value)
144 $this->_familyName = $value;
149 * Get the value for this element's givenName attribute.
152 * @return string The requested attribute.
154 public function getGivenName()
156 return $this->_givenName;
160 * Set the value for this element's givenName attribute. This
161 * represents a user's given name.
163 * @param string $value The desired value for this attribute.
164 * @return Zend_Gdata_Gapps_Extension_Name Provides a fluent interface.
166 public function setGivenName($value)
168 $this->_givenName = $value;
173 * Magic toString method allows using this directly via echo
174 * Works best in PHP >= 4.2.0
176 public function __toString()
178 return $this->getGivenName() . ' ' . $this->getFamilyName();