2
0

BaseAttribute.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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 Gbase
  18. * @copyright Copyright (c) 2005-2012 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_App_Extension_Element
  24. */
  25. require_once 'Zend/Gdata/App/Extension/Element.php';
  26. /**
  27. * Concrete class for working with ItemType elements.
  28. *
  29. * @category Zend
  30. * @package Zend_Gdata
  31. * @subpackage Gbase
  32. * @copyright Copyright (c) 2005-2012 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_Gbase_Extension_BaseAttribute extends Zend_Gdata_App_Extension_Element
  36. {
  37. /**
  38. * Namespace for Google Base elements
  39. *
  40. * var @string
  41. */
  42. protected $_rootNamespace = 'g';
  43. /**
  44. * Create a new instance.
  45. *
  46. * @param string $name (optional) The name of the Base attribute
  47. * @param string $text (optional) The text value of the Base attribute
  48. * @param string $text (optional) The type of the Base attribute
  49. */
  50. public function __construct($name = null, $text = null, $type = null)
  51. {
  52. $this->registerAllNamespaces(Zend_Gdata_Gbase::$namespaces);
  53. if ($type !== null) {
  54. $attr = array('name' => 'type', 'value' => $type);
  55. $typeAttr = array('type' => $attr);
  56. $this->setExtensionAttributes($typeAttr);
  57. }
  58. parent::__construct($name,
  59. $this->_rootNamespace,
  60. $this->lookupNamespace($this->_rootNamespace),
  61. $text);
  62. }
  63. /**
  64. * Get the name of the attribute
  65. *
  66. * @return attribute name The requested object.
  67. */
  68. public function getName() {
  69. return $this->_rootElement;
  70. }
  71. /**
  72. * Get the type of the attribute
  73. *
  74. * @return attribute type The requested object.
  75. */
  76. public function getType() {
  77. $typeAttr = $this->getExtensionAttributes();
  78. return $typeAttr['type']['value'];
  79. }
  80. /**
  81. * Set the 'name' of the Base attribute object:
  82. * &lt;g:[$name] type='[$type]'&gt;[$value]&lt;/g:[$name]&gt;
  83. *
  84. * @param Zend_Gdata_App_Extension_Element $attribute The attribute object
  85. * @param string $name The name of the Base attribute
  86. * @return Zend_Gdata_Extension_ItemEntry Provides a fluent interface
  87. */
  88. public function setName($name) {
  89. $this->_rootElement = $name;
  90. return $this;
  91. }
  92. /**
  93. * Set the 'type' of the Base attribute object:
  94. * &lt;g:[$name] type='[$type]'&gt;[$value]&lt;/g:[$name]&gt;
  95. *
  96. * @param Zend_Gdata_App_Extension_Element $attribute The attribute object
  97. * @param string $type The type of the Base attribute
  98. * @return Zend_Gdata_Extension_ItemEntry Provides a fluent interface
  99. */
  100. public function setType($type) {
  101. $attr = array('name' => 'type', 'value' => $type);
  102. $typeAttr = array('type' => $attr);
  103. $this->setExtensionAttributes($typeAttr);
  104. return $this;
  105. }
  106. }