ContactEntry.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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 YouTube
  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_YouTube_UserProfileEntry
  23. */
  24. require_once 'Zend/Gdata/YouTube/UserProfileEntry.php';
  25. /**
  26. * @see Zend_Gdata_YouTube_Extension_Status
  27. */
  28. require_once 'Zend/Gdata/YouTube/Extension/Status.php';
  29. /**
  30. * The YouTube contacts flavor of an Atom Entry with media support
  31. * Represents a an individual contact
  32. *
  33. * @category Zend
  34. * @package Zend_Gdata
  35. * @subpackage YouTube
  36. * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  37. * @license http://framework.zend.com/license/new-bsd New BSD License
  38. */
  39. class Zend_Gdata_YouTube_ContactEntry extends Zend_Gdata_YouTube_UserProfileEntry
  40. {
  41. /**
  42. * The classname for individual feed elements.
  43. *
  44. * @var string
  45. */
  46. protected $_entryClassName = 'Zend_Gdata_YouTube_ContactEntry';
  47. /**
  48. * Status of the user as a contact
  49. *
  50. * @var string
  51. */
  52. protected $_status = null;
  53. /**
  54. * Constructs a new Contact Entry object, to represent
  55. * an individual contact for a user
  56. *
  57. * @param DOMElement $element (optional) DOMElement from which this
  58. * object should be constructed.
  59. */
  60. public function __construct($element = null)
  61. {
  62. $this->registerAllNamespaces(Zend_Gdata_YouTube::$namespaces);
  63. parent::__construct($element);
  64. }
  65. /**
  66. * Retrieves a DOMElement which corresponds to this element and all
  67. * child properties. This is used to build an entry back into a DOM
  68. * and eventually XML text for sending to the server upon updates, or
  69. * for application storage/persistence.
  70. *
  71. * @param DOMDocument $doc The DOMDocument used to construct DOMElements
  72. * @return DOMElement The DOMElement representing this element and all
  73. * child properties.
  74. */
  75. public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
  76. {
  77. $element = parent::getDOM($doc, $majorVersion, $minorVersion);
  78. if ($this->_status != null) {
  79. $element->appendChild($this->_status->getDOM($element->ownerDocument));
  80. }
  81. return $element;
  82. }
  83. /**
  84. * Creates individual Entry objects of the appropriate type and
  85. * stores them in the $_entry array based upon DOM data.
  86. *
  87. * @param DOMNode $child The DOMNode to process
  88. */
  89. protected function takeChildFromDOM($child)
  90. {
  91. $absoluteNodeName = $child->namespaceURI . ':' . $child->localName;
  92. switch ($absoluteNodeName) {
  93. case $this->lookupNamespace('yt') . ':' . 'status':
  94. $status = new Zend_Gdata_YouTube_Extension_Status();
  95. $status->transferFromDOM($child);
  96. $this->_status = $status;
  97. break;
  98. default:
  99. parent::takeChildFromDOM($child);
  100. break;
  101. }
  102. }
  103. /**
  104. * Sets the status
  105. *
  106. * @param Zend_Gdata_YouTube_Extension_Status $status The status
  107. * @return Zend_Gdata_YouTube_ContactEntry Provides a fluent interface
  108. */
  109. public function setStatus($status = null)
  110. {
  111. $this->_status = $status;
  112. return $this;
  113. }
  114. /**
  115. * Returns the status
  116. *
  117. * @return Zend_Gdata_YouTube_Extension_Status The status
  118. */
  119. public function getStatus()
  120. {
  121. return $this->_status;
  122. }
  123. }