ExtendedProperty.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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. * Data model for gd:extendedProperty element, used by some Gdata
  28. * services to implement arbitrary name/value pair storage
  29. *
  30. * @category Zend
  31. * @package Zend_Gdata
  32. * @subpackage Gdata
  33. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  34. * @license http://framework.zend.com/license/new-bsd New BSD License
  35. */
  36. class Zend_Gdata_Extension_ExtendedProperty extends Zend_Gdata_Extension
  37. {
  38. protected $_rootElement = 'extendedProperty';
  39. protected $_name = null;
  40. protected $_value = null;
  41. public function __construct($name = null, $value = null)
  42. {
  43. parent::__construct();
  44. $this->_name = $name;
  45. $this->_value = $value;
  46. }
  47. public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
  48. {
  49. $element = parent::getDOM($doc, $majorVersion, $minorVersion);
  50. if ($this->_name !== null) {
  51. $element->setAttribute('name', $this->_name);
  52. }
  53. if ($this->_value !== null) {
  54. $element->setAttribute('value', $this->_value);
  55. }
  56. return $element;
  57. }
  58. protected function takeAttributeFromDOM($attribute)
  59. {
  60. switch ($attribute->localName) {
  61. case 'name':
  62. $this->_name = $attribute->nodeValue;
  63. break;
  64. case 'value':
  65. $this->_value = $attribute->nodeValue;
  66. break;
  67. default:
  68. parent::takeAttributeFromDOM($attribute);
  69. }
  70. }
  71. public function __toString()
  72. {
  73. return $this->getName() . '=' . $this->getValue();
  74. }
  75. public function getName()
  76. {
  77. return $this->_name;
  78. }
  79. public function setName($value)
  80. {
  81. $this->_name = $value;
  82. return $this;
  83. }
  84. public function getValue()
  85. {
  86. return $this->_value;
  87. }
  88. public function setValue($value)
  89. {
  90. $this->_value = $value;
  91. return $this;
  92. }
  93. }