2
0

EmailList.php 4.2 KB

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