2
0

NicknameEntry.php 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  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.
  14. *
  15. * @category Zend
  16. * @package Zend_Gdata
  17. * @subpackage Gapps
  18. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. * @version $Id$
  21. */
  22. /**
  23. * @see Zend_Gdata_Entry
  24. */
  25. require_once 'Zend/Gdata/Entry.php';
  26. /**
  27. * @see Zend_Gdata_Gapps_Extension_Login
  28. */
  29. require_once 'Zend/Gdata/Gapps/Extension/Login.php';
  30. /**
  31. * @see Zend_Gdata_Gapps_Extension_Nickname
  32. */
  33. require_once 'Zend/Gdata/Gapps/Extension/Nickname.php';
  34. /**
  35. * Data model class for a Google Apps Nickname Entry.
  36. *
  37. * Each nickname entry describes a single nickname within a Google Apps
  38. * hosted domain. Each user may own several nicknames, but each nickname may
  39. * only belong to one user. Multiple entries are contained within instances
  40. * of Zend_Gdata_Gapps_NicknameFeed.
  41. *
  42. * To transfer nickname entries to and from the Google Apps servers,
  43. * including creating new entries, refer to the Google Apps service class,
  44. * Zend_Gdata_Gapps.
  45. *
  46. * This class represents <atom:entry> in the Google Data protocol.
  47. *
  48. * @category Zend
  49. * @package Zend_Gdata
  50. * @subpackage Gapps
  51. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  52. * @license http://framework.zend.com/license/new-bsd New BSD License
  53. */
  54. class Zend_Gdata_Gapps_NicknameEntry extends Zend_Gdata_Entry
  55. {
  56. protected $_entryClassName = 'Zend_Gdata_Gapps_NicknameEntry';
  57. /**
  58. * <apps:login> element used to hold information about the owner
  59. * of this nickname, including their username.
  60. *
  61. * @var Zend_Gdata_Gapps_Extension_Login
  62. */
  63. protected $_login = null;
  64. /**
  65. * <apps:nickname> element used to hold the name of this nickname.
  66. *
  67. * @var Zend_Gdata_Gapps_Extension_Nickname
  68. */
  69. protected $_nickname = null;
  70. /**
  71. * Create a new instance.
  72. *
  73. * @param DOMElement $element (optional) DOMElement from which this
  74. * object should be constructed.
  75. */
  76. public function __construct($element = null)
  77. {
  78. $this->registerAllNamespaces(Zend_Gdata_Gapps::$namespaces);
  79. parent::__construct($element);
  80. }
  81. /**
  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 application storage/persistence.
  85. *
  86. * @param DOMDocument $doc The DOMDocument used to construct DOMElements
  87. * @return DOMElement The DOMElement representing this element and all
  88. * child properties.
  89. */
  90. public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
  91. {
  92. $element = parent::getDOM($doc, $majorVersion, $minorVersion);
  93. if ($this->_login !== null) {
  94. $element->appendChild($this->_login->getDOM($element->ownerDocument));
  95. }
  96. if ($this->_nickname !== null) {
  97. $element->appendChild($this->_nickname->getDOM($element->ownerDocument));
  98. }
  99. return $element;
  100. }
  101. /**
  102. * Creates individual Entry objects of the appropriate type and
  103. * stores them as members of this entry based upon DOM data.
  104. *
  105. * @param DOMNode $child The DOMNode to process
  106. */
  107. protected function takeChildFromDOM($child)
  108. {
  109. $absoluteNodeName = $child->namespaceURI . ':' . $child->localName;
  110. switch ($absoluteNodeName) {
  111. case $this->lookupNamespace('apps') . ':' . 'login';
  112. $login = new Zend_Gdata_Gapps_Extension_Login();
  113. $login->transferFromDOM($child);
  114. $this->_login = $login;
  115. break;
  116. case $this->lookupNamespace('apps') . ':' . 'nickname';
  117. $nickname = new Zend_Gdata_Gapps_Extension_Nickname();
  118. $nickname->transferFromDOM($child);
  119. $this->_nickname = $nickname;
  120. break;
  121. default:
  122. parent::takeChildFromDOM($child);
  123. break;
  124. }
  125. }
  126. /**
  127. * Get the value of the login property for this object.
  128. *
  129. * @see setLogin
  130. * @return Zend_Gdata_Gapps_Extension_Login The requested object.
  131. */
  132. public function getLogin()
  133. {
  134. return $this->_login;
  135. }
  136. /**
  137. * Set the value of the login property for this object. This property
  138. * is used to store the username address of the current user.
  139. *
  140. * @param Zend_Gdata_Gapps_Extension_Login $value The desired value for
  141. * this instance's login property.
  142. * @return Zend_Gdata_Gapps_NicknameEntry Provides a fluent interface.
  143. */
  144. public function setLogin($value)
  145. {
  146. $this->_login = $value;
  147. return $this;
  148. }
  149. /**
  150. * Get the value of the nickname property for this object.
  151. *
  152. * @see setNickname
  153. * @return Zend_Gdata_Gapps_Extension_Nickname The requested object.
  154. */
  155. public function getNickname()
  156. {
  157. return $this->_nickname;
  158. }
  159. /**
  160. * Set the value of the nickname property for this object. This property
  161. * is used to store the the name of the current nickname.
  162. *
  163. * @param Zend_Gdata_Gapps_Extension_Nickname $value The desired value for
  164. * this instance's nickname property.
  165. * @return Zend_Gdata_Gapps_NicknameEntry Provides a fluent interface.
  166. */
  167. public function setNickname($value)
  168. {
  169. $this->_nickname = $value;
  170. return $this;
  171. }
  172. }