source: trunk/www.guidonia.net/wp/wp-content/plugins/webtv/Drivers/Zend/Gdata/Gapps/Extension/Nickname.php@ 44

Last change on this file since 44 was 44, checked in by luciano, 14 years ago
File size: 4.1 KB
Line 
1<?php
2
3/**
4 * Zend Framework
5 *
6 * LICENSE
7 *
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.
15 *
16 * @category Zend
17 * @package Zend_Gdata
18 * @subpackage Gapps
19 * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
20 * @license http://framework.zend.com/license/new-bsd New BSD License
21 */
22
23/**
24 * @see Zend_Gdata_Extension
25 */
26require_once 'Zend/Gdata/Extension.php';
27
28/**
29 * @see Zend_Gdata_Gapps
30 */
31require_once 'Zend/Gdata/Gapps.php';
32
33/**
34 * Represents the apps:nickname element used by the Apps data API. This
35 * is used to describe a nickname's properties, and is usually contained
36 * within instances of Zend_Gdata_Gapps_NicknameEntry.
37 *
38 * @category Zend
39 * @package Zend_Gdata
40 * @subpackage Gapps
41 * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
42 * @license http://framework.zend.com/license/new-bsd New BSD License
43 */
44class Zend_Gdata_Gapps_Extension_Nickname extends Zend_Gdata_Extension
45{
46
47 protected $_rootNamespace = 'apps';
48 protected $_rootElement = 'nickname';
49
50 /**
51 * The name of the nickname. This name is used as the email address
52 * for this nickname.
53 *
54 * @var string
55 */
56 protected $_name = null;
57
58 /**
59 * Constructs a new Zend_Gdata_Gapps_Extension_Nickname object.
60 * @param string $name (optional) The nickname being represented.
61 */
62 public function __construct($name = null)
63 {
64 $this->registerAllNamespaces(Zend_Gdata_Gapps::$namespaces);
65 parent::__construct();
66 $this->_name = $name;
67 }
68
69 /**
70 * Retrieves a DOMElement which corresponds to this element and all
71 * child properties. This is used to build an entry back into a DOM
72 * and eventually XML text for sending to the server upon updates, or
73 * for application storage/persistence.
74 *
75 * @param DOMDocument $doc The DOMDocument used to construct DOMElements
76 * @return DOMElement The DOMElement representing this element and all
77 * child properties.
78 */
79 public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
80 {
81 $element = parent::getDOM($doc, $majorVersion, $minorVersion);
82 if ($this->_name !== null) {
83 $element->setAttribute('name', $this->_name);
84 }
85 return $element;
86 }
87
88 /**
89 * Given a DOMNode representing an attribute, tries to map the data into
90 * instance members. If no mapping is defined, the name and value are
91 * stored in an array.
92 *
93 * @param DOMNode $attribute The DOMNode attribute needed to be handled
94 */
95 protected function takeAttributeFromDOM($attribute)
96 {
97 switch ($attribute->localName) {
98 case 'name':
99 $this->_name = $attribute->nodeValue;
100 break;
101 default:
102 parent::takeAttributeFromDOM($attribute);
103 }
104 }
105
106 /**
107 * Get the value for this element's name attribute.
108 *
109 * @see setName
110 * @return string The requested attribute.
111 */
112 public function getName()
113 {
114 return $this->_name;
115 }
116
117 /**
118 * Set the value for this element's name attribute. This name uniquely
119 * describes this nickname within the domain. Emails addressed to this
120 * name will be delivered to the user who owns this nickname.
121 *
122 * @param string $value The desired value for this attribute.
123 * @return Zend_Gdata_Gapps_Extension_Nickname Provides a fluent
124 * interface.
125 */
126 public function setName($value)
127 {
128 $this->_name = $value;
129 return $this;
130 }
131
132 /**
133 * Magic toString method allows using this directly via echo
134 * Works best in PHP >= 4.2.0
135 */
136 public function __toString()
137 {
138 return $this->getName();
139 }
140
141}
Note: See TracBrowser for help on using the repository browser.