EmailList.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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-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. * @see Zend_Gdata_Gapps
  27. */
  28. require_once 'Zend/Gdata/Gapps.php';
  29. /**
  30. * Represents the apps:emailList element used by the Apps data API. This
  31. * class represents properties of an email list and is usually contained
  32. * within an instance of Zend_Gdata_Gapps_EmailListEntry.
  33. *
  34. * @category Zend
  35. * @package Zend_Gdata
  36. * @subpackage Gapps
  37. * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  38. * @license http://framework.zend.com/license/new-bsd New BSD License
  39. */
  40. class Zend_Gdata_Gapps_Extension_EmailList extends Zend_Gdata_Extension
  41. {
  42. protected $_rootNamespace = 'apps';
  43. protected $_rootElement = 'emailList';
  44. /**
  45. * The name of the email list. This name is used as the email address
  46. * for this list.
  47. *
  48. * @var string
  49. */
  50. protected $_name = null;
  51. /**
  52. * Constructs a new Zend_Gdata_Gapps_Extension_EmailList object.
  53. *
  54. * @param string $name (optional) The name to be used for this email list.
  55. */
  56. public function __construct($name = null)
  57. {
  58. $this->registerAllNamespaces(Zend_Gdata_Gapps::$namespaces);
  59. parent::__construct();
  60. $this->_name = $name;
  61. }
  62. /**
  63. * Retrieves a DOMElement which corresponds to this element and all
  64. * child properties. This is used to build an entry back into a DOM
  65. * and eventually XML text for sending to the server upon updates, or
  66. * for application storage/persistence.
  67. *
  68. * @param DOMDocument $doc The DOMDocument used to construct DOMElements
  69. * @return DOMElement The DOMElement representing this element and all
  70. * child properties.
  71. */
  72. public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
  73. {
  74. $element = parent::getDOM($doc, $majorVersion, $minorVersion);
  75. if ($this->_name !== null) {
  76. $element->setAttribute('name', $this->_name);
  77. }
  78. return $element;
  79. }
  80. /**
  81. * Given a DOMNode representing an attribute, tries to map the data into
  82. * instance members. If no mapping is defined, the name and value are
  83. * stored in an array.
  84. *
  85. * @param DOMNode $attribute The DOMNode attribute needed to be handled
  86. */
  87. protected function takeAttributeFromDOM($attribute)
  88. {
  89. switch ($attribute->localName) {
  90. case 'name':
  91. $this->_name = $attribute->nodeValue;
  92. break;
  93. default:
  94. parent::takeAttributeFromDOM($attribute);
  95. }
  96. }
  97. /**
  98. * Get the value for this element's name attribute.
  99. *
  100. * @see setName
  101. * @return string The requested attribute.
  102. */
  103. public function getName()
  104. {
  105. return $this->_name;
  106. }
  107. /**
  108. * Set the value for this element's name attribute. This is the unique
  109. * name which will be used to identify this email list within this
  110. * domain, and will be used to form this email list's email address.
  111. *
  112. * @param string $value The desired value for this attribute.
  113. * @return Zend_Gdata_Gapps_Extension_EmailList The element being modified.
  114. */
  115. public function setName($value)
  116. {
  117. $this->_name = $value;
  118. return $this;
  119. }
  120. /**
  121. * Magic toString method allows using this directly via echo
  122. * Works best in PHP >= 4.2.0
  123. *
  124. * @return string
  125. */
  126. public function __toString()
  127. {
  128. return $this->getName();
  129. }
  130. }