Embeddability.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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 Books
  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. * Describes an embeddability
  28. *
  29. * @category Zend
  30. * @package Zend_Gdata
  31. * @subpackage Books
  32. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  33. * @license http://framework.zend.com/license/new-bsd New BSD License
  34. */
  35. class Zend_Gdata_Books_Extension_Embeddability extends Zend_Gdata_Extension
  36. {
  37. protected $_rootNamespace = 'gbs';
  38. protected $_rootElement = 'embeddability';
  39. protected $_value = null;
  40. /**
  41. * Constructor for Zend_Gdata_Books_Extension_Embeddability which
  42. * Describes an embeddability.
  43. *
  44. * @param string|null $value A programmatic value representing the book's
  45. * embeddability.
  46. */
  47. public function __construct($value = null)
  48. {
  49. $this->registerAllNamespaces(Zend_Gdata_Books::$namespaces);
  50. parent::__construct();
  51. $this->_value = $value;
  52. }
  53. /**
  54. * Retrieves DOMElement which corresponds to this element and all
  55. * child properties. This is used to build this object back into a DOM
  56. * and eventually XML text for sending to the server upon updates, or
  57. * for application storage/persistance.
  58. *
  59. * @param DOMDocument $doc The DOMDocument used to construct DOMElements
  60. * @return DOMElement The DOMElement representing this element and all
  61. * child properties.
  62. */
  63. public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
  64. {
  65. $element = parent::getDOM($doc);
  66. if ($this->_value !== null) {
  67. $element->setAttribute('value', $this->_value);
  68. }
  69. return $element;
  70. }
  71. /**
  72. * Extracts XML attributes from the DOM and converts them to the
  73. * appropriate object members.
  74. *
  75. * @param DOMNode $attribute The DOMNode attribute to be handled.
  76. */
  77. protected function takeAttributeFromDOM($attribute)
  78. {
  79. switch ($attribute->localName) {
  80. case 'value':
  81. $this->_value = $attribute->nodeValue;
  82. break;
  83. default:
  84. parent::takeAttributeFromDOM($attribute);
  85. }
  86. }
  87. /**
  88. * Returns the programmatic value that describes the embeddability of a
  89. * volume in Google Book Search
  90. *
  91. * @return string|null The value
  92. */
  93. public function getValue()
  94. {
  95. return $this->_value;
  96. }
  97. /**
  98. * Sets the programmatic value that describes the embeddability of a
  99. * volume in Google Book Search
  100. *
  101. * @param string|null $value Programmatic value that describes the
  102. * embeddability of a volume in Google Book Search
  103. * @return Zend_Gdata_Books_Extension_Embeddability Provides a fluent
  104. * interface
  105. */
  106. public function setValue($value)
  107. {
  108. $this->_value = $value;
  109. return $this;
  110. }
  111. }