RecurrenceException.php 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  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 Gdata
  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_Extension
  24. */
  25. require_once 'Zend/Gdata/Extension.php';
  26. /**
  27. * @see Zend_Gdata_Extension_EntryLink
  28. */
  29. require_once 'Zend/Gdata/Extension/EntryLink.php';
  30. /**
  31. * @see Zend_Gdata_Extension_OriginalEvent
  32. */
  33. require_once 'Zend/Gdata/Extension/OriginalEvent.php';
  34. /**
  35. * Data model class to represent an entry's recurrenceException
  36. *
  37. * @category Zend
  38. * @package Zend_Gdata
  39. * @subpackage Gdata
  40. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  41. * @license http://framework.zend.com/license/new-bsd New BSD License
  42. */
  43. class Zend_Gdata_Extension_RecurrenceException extends Zend_Gdata_Extension
  44. {
  45. protected $_rootElement = 'recurrenceException';
  46. protected $_specialized = null;
  47. protected $_entryLink = null;
  48. protected $_originalEvent = null;
  49. /**
  50. * Constructs a new Zend_Gdata_Extension_RecurrenceException object.
  51. * @param bool $specialized (optional) Whether this is a specialized exception or not.
  52. * @param Zend_Gdata_EntryLink (optional) An Event entry with details about the exception.
  53. * @param Zend_Gdata_OriginalEvent (optional) The origianl recurrent event this is an exeption to.
  54. */
  55. public function __construct($specialized = null, $entryLink = null,
  56. $originalEvent = null)
  57. {
  58. parent::__construct();
  59. $this->_specialized = $specialized;
  60. $this->_entryLink = $entryLink;
  61. $this->_originalEvent = $originalEvent;
  62. }
  63. /**
  64. * Retrieves a DOMElement which corresponds to this element and all
  65. * child properties. This is used to build an entry back into a DOM
  66. * and eventually XML text for sending to the server upon updates, or
  67. * for application storage/persistence.
  68. *
  69. * @param DOMDocument $doc The DOMDocument used to construct DOMElements
  70. * @return DOMElement The DOMElement representing this element and all
  71. * child properties.
  72. */
  73. public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
  74. {
  75. $element = parent::getDOM($doc, $majorVersion, $minorVersion);
  76. if ($this->_specialized !== null) {
  77. $element->setAttribute('specialized', ($this->_specialized ? "true" : "false"));
  78. }
  79. if ($this->_entryLink !== null) {
  80. $element->appendChild($this->_entryLink->getDOM($element->ownerDocument));
  81. }
  82. if ($this->_originalEvent !== null) {
  83. $element->appendChild($this->_originalEvent->getDOM($element->ownerDocument));
  84. }
  85. return $element;
  86. }
  87. /**
  88. * Given a DOMNode representing an attribute, tries to map the data into
  89. * instance members. If no mapping is defined, the name and value are
  90. * stored in an array.
  91. *
  92. * @param DOMNode $attribute The DOMNode attribute needed to be handled
  93. */
  94. protected function takeAttributeFromDOM($attribute)
  95. {
  96. switch ($attribute->localName) {
  97. case 'specialized':
  98. if ($attribute->nodeValue == "true") {
  99. $this->_specialized = true;
  100. }
  101. else if ($attribute->nodeValue == "false") {
  102. $this->_specialized = false;
  103. }
  104. else {
  105. throw new Zend_Gdata_App_InvalidArgumentException("Expected 'true' or 'false' for gCal:selected#value.");
  106. }
  107. break;
  108. default:
  109. parent::takeAttributeFromDOM($attribute);
  110. }
  111. }
  112. /**
  113. * Creates individual Entry objects of the appropriate type and
  114. * stores them as members of this entry based upon DOM data.
  115. *
  116. * @param DOMNode $child The DOMNode to process
  117. */
  118. protected function takeChildFromDOM($child)
  119. {
  120. $absoluteNodeName = $child->namespaceURI . ':' . $child->localName;
  121. switch ($absoluteNodeName) {
  122. case $this->lookupNamespace('gd') . ':' . 'entryLink':
  123. $entryLink = new Zend_Gdata_Extension_EntryLink();
  124. $entryLink->transferFromDOM($child);
  125. $this->_entryLink = $entryLink;
  126. break;
  127. case $this->lookupNamespace('gd') . ':' . 'originalEvent':
  128. $originalEvent = new Zend_Gdata_Extension_OriginalEvent();
  129. $originalEvent->transferFromDOM($child);
  130. $this->_originalEvent = $originalEvent;
  131. break;
  132. default:
  133. parent::takeChildFromDOM($child);
  134. break;
  135. }
  136. }
  137. /**
  138. * Get the value for this element's Specialized attribute.
  139. *
  140. * @return bool The requested attribute.
  141. */
  142. public function getSpecialized()
  143. {
  144. return $this->_specialized;
  145. }
  146. /**
  147. * Set the value for this element's Specialized attribute.
  148. *
  149. * @param bool $value The desired value for this attribute.
  150. * @return Zend_Gdata_Extension_RecurrenceException The element being modified.
  151. */
  152. public function setSpecialized($value)
  153. {
  154. $this->_specialized = $value;
  155. return $this;
  156. }
  157. /**
  158. * Get the value for this element's EntryLink attribute.
  159. *
  160. * @return Zend_Gdata_Extension_EntryLink The requested attribute.
  161. */
  162. public function getEntryLink()
  163. {
  164. return $this->_entryLink;
  165. }
  166. /**
  167. * Set the value for this element's EntryLink attribute.
  168. *
  169. * @param Zend_Gdata_Extension_EntryLink $value The desired value for this attribute.
  170. * @return Zend_Gdata_Extension_RecurrenceException The element being modified.
  171. */
  172. public function setEntryLink($value)
  173. {
  174. $this->_entryLink = $value;
  175. return $this;
  176. }
  177. /**
  178. * Get the value for this element's Specialized attribute.
  179. *
  180. * @return Zend_Gdata_Extension_OriginalEvent The requested attribute.
  181. */
  182. public function getOriginalEvent()
  183. {
  184. return $this->_originalEvent;
  185. }
  186. /**
  187. * Set the value for this element's Specialized attribute.
  188. *
  189. * @param Zend_Gdata_Extension_OriginalEvent $value The desired value for this attribute.
  190. * @return Zend_Gdata_Extension_RecurrenceException The element being modified.
  191. */
  192. public function setOriginalEvent($value)
  193. {
  194. $this->_originalEvent = $value;
  195. return $this;
  196. }
  197. }