2
0

Control.php 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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 App
  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_App_Extension
  24. */
  25. require_once 'Zend/Gdata/App/Extension.php';
  26. /**
  27. * @see Zend_Gdata_App_Extension_Draft
  28. */
  29. require_once 'Zend/Gdata/App/Extension/Draft.php';
  30. /**
  31. * Represents the app:control element
  32. *
  33. * @category Zend
  34. * @package Zend_Gdata
  35. * @subpackage App
  36. * @copyright Copyright (c) 2005-2015 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_App_Extension_Control extends Zend_Gdata_App_Extension
  40. {
  41. protected $_rootNamespace = 'app';
  42. protected $_rootElement = 'control';
  43. protected $_draft = null;
  44. public function __construct($draft = null)
  45. {
  46. parent::__construct();
  47. $this->_draft = $draft;
  48. }
  49. public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
  50. {
  51. $element = parent::getDOM($doc, $majorVersion, $minorVersion);
  52. if ($this->_draft != null) {
  53. $element->appendChild($this->_draft->getDOM($element->ownerDocument));
  54. }
  55. return $element;
  56. }
  57. protected function takeChildFromDOM($child)
  58. {
  59. $absoluteNodeName = $child->namespaceURI . ':' . $child->localName;
  60. switch ($absoluteNodeName) {
  61. case $this->lookupNamespace('app') . ':' . 'draft':
  62. $draft = new Zend_Gdata_App_Extension_Draft();
  63. $draft->transferFromDOM($child);
  64. $this->_draft = $draft;
  65. break;
  66. default:
  67. parent::takeChildFromDOM($child);
  68. break;
  69. }
  70. }
  71. /**
  72. * @return Zend_Gdata_App_Extension_Draft
  73. */
  74. public function getDraft()
  75. {
  76. return $this->_draft;
  77. }
  78. /**
  79. * @param Zend_Gdata_App_Extension_Draft $value
  80. * @return Zend_Gdata_App_Entry Provides a fluent interface
  81. */
  82. public function setDraft($value)
  83. {
  84. $this->_draft = $value;
  85. return $this;
  86. }
  87. }