]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - Zend/Gdata/App/Extension/Control.php
Release 6.5.0
[Github/sugarcrm.git] / Zend / Gdata / App / Extension / Control.php
1 <?php
2
3 /**
4  * Zend Framework
5  *
6  * LICENSE
7  *
8  * This source file is subject to the new BSD license that is bundled
9  * with this package in the file LICENSE.txt.
10  * It is also available through the world-wide-web at this URL:
11  * http://framework.zend.com/license/new-bsd
12  * If you did not receive a copy of the license and are unable to
13  * obtain it through the world-wide-web, please send an email
14  * to license@zend.com so we can send you a copy immediately.
15  *
16  * @category   Zend
17  * @package    Zend_Gdata
18  * @subpackage App
19  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
20  * @license    http://framework.zend.com/license/new-bsd     New BSD License
21
22  */
23
24 /**
25  * @see Zend_Gdata_App_Extension
26  */
27 require_once 'Zend/Gdata/App/Extension.php';
28
29 /**
30  * @see Zend_Gdata_App_Extension_Draft
31  */
32 require_once 'Zend/Gdata/App/Extension/Draft.php';
33
34 /**
35  * Represents the app:control element
36  *
37  * @category   Zend
38  * @package    Zend_Gdata
39  * @subpackage App
40  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
41  * @license    http://framework.zend.com/license/new-bsd     New BSD License
42  */
43 class Zend_Gdata_App_Extension_Control extends Zend_Gdata_App_Extension
44 {
45
46     protected $_rootNamespace = 'app';
47     protected $_rootElement = 'control';
48     protected $_draft = null;
49
50     public function __construct($draft = null)
51     {
52         parent::__construct();
53         $this->_draft = $draft;
54     }
55
56     public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
57     {
58         $element = parent::getDOM($doc, $majorVersion, $minorVersion);
59         if ($this->_draft != null) {
60             $element->appendChild($this->_draft->getDOM($element->ownerDocument));
61         }
62         return $element;
63     }
64
65     protected function takeChildFromDOM($child)
66     {
67         $absoluteNodeName = $child->namespaceURI . ':' . $child->localName;
68         switch ($absoluteNodeName) {
69         case $this->lookupNamespace('app') . ':' . 'draft':
70             $draft = new Zend_Gdata_App_Extension_Draft();
71             $draft->transferFromDOM($child);
72             $this->_draft = $draft;
73             break;
74         default:
75             parent::takeChildFromDOM($child);
76             break;
77         }
78     }
79
80     /**
81      * @return Zend_Gdata_App_Extension_Draft
82      */
83     public function getDraft()
84     {
85         return $this->_draft;
86     }
87
88     /**
89      * @param Zend_Gdata_App_Extension_Draft $value
90      * @return Zend_Gdata_App_Entry Provides a fluent interface
91      */
92     public function setDraft($value)
93     {
94         $this->_draft = $value;
95         return $this;
96     }
97
98 }