2
0

SendEventNotifications.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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 Calendar
  18. * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. */
  21. /**
  22. * @see Zend_Gdata_Extension
  23. */
  24. require_once 'Zend/Gdata/Extension.php';
  25. /**
  26. * Data model class to represent an entry's sendEventNotifications
  27. *
  28. * @category Zend
  29. * @package Zend_Gdata
  30. * @subpackage Calendar
  31. * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  32. * @license http://framework.zend.com/license/new-bsd New BSD License
  33. */
  34. class Zend_Gdata_Calendar_Extension_SendEventNotifications extends Zend_Gdata_Extension
  35. {
  36. protected $_rootNamespace = 'gCal';
  37. protected $_rootElement = 'sendEventNotifications';
  38. protected $_value = null;
  39. /**
  40. * Constructs a new Zend_Gdata_Extension_SendEventNotifications object.
  41. * @param bool $value (optional) SendEventNotifications value as URI.
  42. */
  43. public function __construct($value = null)
  44. {
  45. $this->registerAllNamespaces(Zend_Gdata_Calendar::$namespaces);
  46. parent::__construct();
  47. $this->_value = $value;
  48. }
  49. /**
  50. * Retrieves a DOMElement which corresponds to this element and all
  51. * child properties. This is used to build an entry back into a DOM
  52. * and eventually XML text for sending to the server upon updates, or
  53. * for application storage/persistence.
  54. *
  55. * @param DOMDocument $doc The DOMDocument used to construct DOMElements
  56. * @return DOMElement The DOMElement representing this element and all
  57. * child properties.
  58. */
  59. public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
  60. {
  61. $element = parent::getDOM($doc, $majorVersion, $minorVersion);
  62. if ($this->_value !== null) {
  63. $element->setAttribute('value', ($this->_value ? "true" : "false"));
  64. }
  65. return $element;
  66. }
  67. /**
  68. * Given a DOMNode representing an attribute, tries to map the data into
  69. * instance members. If no mapping is defined, the name and value are
  70. * stored in an array.
  71. *
  72. * @param DOMNode $attribute The DOMNode attribute needed to be handled
  73. */
  74. protected function takeAttributeFromDOM($attribute)
  75. {
  76. switch ($attribute->localName) {
  77. case 'value':
  78. if ($attribute->nodeValue == "true") {
  79. $this->_value = true;
  80. }
  81. else if ($attribute->nodeValue == "false") {
  82. $this->_value = false;
  83. }
  84. else {
  85. throw new Zend_Gdata_App_InvalidArgumentException("Expected 'true' or 'false' for gCal:selected#value.");
  86. }
  87. break;
  88. default:
  89. parent::takeAttributeFromDOM($attribute);
  90. }
  91. }
  92. /**
  93. * Get the value for this element's Value attribute.
  94. *
  95. * @return string The requested attribute.
  96. */
  97. public function getValue()
  98. {
  99. return $this->_value;
  100. }
  101. /**
  102. * Set the value for this element's Value attribute.
  103. *
  104. * @param string $value The desired value for this attribute.
  105. * @return Zend_Gdata_Extension_SendEventNotifications The element being modified.
  106. */
  107. public function setValue($value)
  108. {
  109. $this->_value = $value;
  110. return $this;
  111. }
  112. /**
  113. * Magic toString method allows using this directly via echo
  114. * Works best in PHP >= 4.2.0
  115. */
  116. public function __toString()
  117. {
  118. return $this->getValue();
  119. }
  120. }