2
0

MemberEntry.php 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  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_Property
  28. */
  29. require_once 'Zend/Gdata/Gapps/Extension/Property.php';
  30. /**
  31. * Data model class for a Google Apps Member Entry.
  32. *
  33. * Each member entry describes a single member within a Google Apps hosted
  34. * domain.
  35. *
  36. * To transfer member entries to and from the Google Apps servers, including
  37. * creating new entries, refer to the Google Apps service class,
  38. * Zend_Gdata_Gapps.
  39. *
  40. * This class represents <atom:entry> in the Google Data protocol.
  41. *
  42. * @category Zend
  43. * @package Zend_Gdata
  44. * @subpackage Gapps
  45. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  46. * @license http://framework.zend.com/license/new-bsd New BSD License
  47. */
  48. class Zend_Gdata_Gapps_MemberEntry extends Zend_Gdata_Entry
  49. {
  50. protected $_entryClassName = 'Zend_Gdata_Gapps_MemberEntry';
  51. /**
  52. * <apps:property> element containing information about other items
  53. * relevant to this entry.
  54. *
  55. * @var Zend_Gdata_Gapps_Extension_Property
  56. */
  57. protected $_property = array();
  58. /**
  59. * Create a new instance.
  60. *
  61. * @param DOMElement $element (optional) DOMElement from which this
  62. * object should be constructed.
  63. */
  64. public function __construct($element = null)
  65. {
  66. $this->registerAllNamespaces(Zend_Gdata_Gapps::$namespaces);
  67. parent::__construct($element);
  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 application storage/persistence.
  73. *
  74. * @param DOMDocument $doc The DOMDocument used to construct DOMElements
  75. * @return DOMElement The DOMElement representing this element and all
  76. * child properties.
  77. */
  78. public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
  79. {
  80. $element = parent::getDOM($doc, $majorVersion, $minorVersion);
  81. foreach ($this->_property as $p) {
  82. $element->appendChild($p->getDOM($element->ownerDocument));
  83. }
  84. return $element;
  85. }
  86. /**
  87. * Creates individual Entry objects of the appropriate type and
  88. * stores them as members of this entry based upon DOM data.
  89. *
  90. * @param DOMNode $child The DOMNode to process
  91. */
  92. protected function takeChildFromDOM($child)
  93. {
  94. $absoluteNodeName = $child->namespaceURI . ':' . $child->localName;
  95. switch ($absoluteNodeName) {
  96. case $this->lookupNamespace('apps') . ':' . 'property';
  97. $property = new Zend_Gdata_Gapps_Extension_Property();
  98. $property->transferFromDOM($child);
  99. $this->_property[] = $property;
  100. break;
  101. default:
  102. parent::takeChildFromDOM($child);
  103. break;
  104. }
  105. }
  106. /**
  107. * Returns all property tags for this entry
  108. *
  109. * @param string $rel The rel value of the property to be found. If null,
  110. * the array of properties is returned instead.
  111. * @return mixed Either an array of Zend_Gdata_Gapps_Extension_Property
  112. * objects if $rel is null, a single
  113. * Zend_Gdata_Gapps_Extension_Property object if $rel is specified
  114. * and a matching feed link is found, or null if $rel is
  115. * specified and no matching property is found.
  116. */
  117. public function getProperty($rel = null)
  118. {
  119. if ($rel == null) {
  120. return $this->_property;
  121. } else {
  122. foreach ($this->_property as $p) {
  123. if ($p->rel == $rel) {
  124. return $p;
  125. }
  126. }
  127. return null;
  128. }
  129. }
  130. /**
  131. * Set the value of the property property for this object.
  132. *
  133. * @param array $value A collection of
  134. * Zend_Gdata_Gapps_Extension_Property objects.
  135. * @return Zend_Gdata_Gapps_MemberEntry Provides a fluent interface.
  136. */
  137. public function setProperty($value)
  138. {
  139. $this->_property = $value;
  140. return $this;
  141. }
  142. }