ContactEntry.php 3.9 KB

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