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:nickname element used by the Apps data API. This
36 * is used to describe a nickname's properties, and is usually contained
37 * within instances of Zend_Gdata_Gapps_NicknameEntry.
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_Nickname extends Zend_Gdata_Extension
48 protected $_rootNamespace = 'apps';
49 protected $_rootElement = 'nickname';
52 * The name of the nickname. This name is used as the email address
57 protected $_name = null;
60 * Constructs a new Zend_Gdata_Gapps_Extension_Nickname object.
61 * @param string $name (optional) The nickname being represented.
63 public function __construct($name = null)
65 $this->registerAllNamespaces(Zend_Gdata_Gapps::$namespaces);
66 parent::__construct();
71 * Retrieves a DOMElement which corresponds to this element and all
72 * child properties. This is used to build an entry back into a DOM
73 * and eventually XML text for sending to the server upon updates, or
74 * for application storage/persistence.
76 * @param DOMDocument $doc The DOMDocument used to construct DOMElements
77 * @return DOMElement The DOMElement representing this element and all
80 public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
82 $element = parent::getDOM($doc, $majorVersion, $minorVersion);
83 if ($this->_name !== null) {
84 $element->setAttribute('name', $this->_name);
90 * Given a DOMNode representing an attribute, tries to map the data into
91 * instance members. If no mapping is defined, the name and value are
94 * @param DOMNode $attribute The DOMNode attribute needed to be handled
96 protected function takeAttributeFromDOM($attribute)
98 switch ($attribute->localName) {
100 $this->_name = $attribute->nodeValue;
103 parent::takeAttributeFromDOM($attribute);
108 * Get the value for this element's name attribute.
111 * @return string The requested attribute.
113 public function getName()
119 * Set the value for this element's name attribute. This name uniquely
120 * describes this nickname within the domain. Emails addressed to this
121 * name will be delivered to the user who owns this nickname.
123 * @param string $value The desired value for this attribute.
124 * @return Zend_Gdata_Gapps_Extension_Nickname Provides a fluent
127 public function setName($value)
129 $this->_name = $value;
134 * Magic toString method allows using this directly via echo
135 * Works best in PHP >= 4.2.0
137 public function __toString()
139 return $this->getName();