|
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 Media |
|
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 * @version $Id: MediaRestriction.php 20096 2010-01-06 02:05:09Z bkarwin $ |
|
22 */ |
|
23 |
|
24 /** |
|
25 * @see Zend_Gdata_App_Extension |
|
26 */ |
|
27 require_once 'Zend/Gdata/App/Extension.php'; |
|
28 |
|
29 /** |
|
30 * Represents the media:restriction element |
|
31 * |
|
32 * @category Zend |
|
33 * @package Zend_Gdata |
|
34 * @subpackage Media |
|
35 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) |
|
36 * @license http://framework.zend.com/license/new-bsd New BSD License |
|
37 */ |
|
38 class Zend_Gdata_Media_Extension_MediaRestriction extends Zend_Gdata_Extension |
|
39 { |
|
40 |
|
41 protected $_rootElement = 'restriction'; |
|
42 protected $_rootNamespace = 'media'; |
|
43 |
|
44 /** |
|
45 * @var string |
|
46 */ |
|
47 protected $_relationship = null; |
|
48 |
|
49 /** |
|
50 * @var string |
|
51 */ |
|
52 protected $_type = null; |
|
53 |
|
54 /** |
|
55 * Constructs a new MediaRestriction element |
|
56 * |
|
57 * @param string $text |
|
58 * @param string $relationship |
|
59 * @param string $type |
|
60 */ |
|
61 public function __construct($text = null, $relationship = null, $type = null) |
|
62 { |
|
63 $this->registerAllNamespaces(Zend_Gdata_Media::$namespaces); |
|
64 parent::__construct(); |
|
65 $this->_text = $text; |
|
66 $this->_relationship = $relationship; |
|
67 $this->_type = $type; |
|
68 } |
|
69 |
|
70 /** |
|
71 * Retrieves a DOMElement which corresponds to this element and all |
|
72 * child properties. This is used to build an entry back into a DOM |
|
73 * and eventually XML text for sending to the server upon updates, or |
|
74 * for application storage/persistence. |
|
75 * |
|
76 * @param DOMDocument $doc The DOMDocument used to construct DOMElements |
|
77 * @return DOMElement The DOMElement representing this element and all |
|
78 * child properties. |
|
79 */ |
|
80 public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null) |
|
81 { |
|
82 $element = parent::getDOM($doc, $majorVersion, $minorVersion); |
|
83 if ($this->_relationship !== null) { |
|
84 $element->setAttribute('relationship', $this->_relationship); |
|
85 } |
|
86 if ($this->_type !== null) { |
|
87 $element->setAttribute('type', $this->_type); |
|
88 } |
|
89 return $element; |
|
90 } |
|
91 |
|
92 /** |
|
93 * Given a DOMNode representing an attribute, tries to map the data into |
|
94 * instance members. If no mapping is defined, the name and value are |
|
95 * stored in an array. |
|
96 * |
|
97 * @param DOMNode $attribute The DOMNode attribute needed to be handled |
|
98 */ |
|
99 protected function takeAttributeFromDOM($attribute) |
|
100 { |
|
101 switch ($attribute->localName) { |
|
102 case 'relationship': |
|
103 $this->_relationship = $attribute->nodeValue; |
|
104 break; |
|
105 case 'type': |
|
106 $this->_type = $attribute->nodeValue; |
|
107 break; |
|
108 default: |
|
109 parent::takeAttributeFromDOM($attribute); |
|
110 } |
|
111 } |
|
112 |
|
113 /** |
|
114 * @return string |
|
115 */ |
|
116 public function getRelationship() |
|
117 { |
|
118 return $this->_relationship; |
|
119 } |
|
120 |
|
121 /** |
|
122 * @param string $value |
|
123 * @return Zend_Gdata_Media_Extension_MediaRestriction Provides a fluent interface |
|
124 */ |
|
125 public function setRelationship($value) |
|
126 { |
|
127 $this->_relationship = $value; |
|
128 return $this; |
|
129 } |
|
130 |
|
131 /** |
|
132 * @return string |
|
133 */ |
|
134 public function getType() |
|
135 { |
|
136 return $this->_type; |
|
137 } |
|
138 |
|
139 /** |
|
140 * @param string $value |
|
141 * @return Zend_Gdata_Media_Extension_MediaRestriction Provides a fluent interface |
|
142 */ |
|
143 public function setType($value) |
|
144 { |
|
145 $this->_type = $value; |
|
146 return $this; |
|
147 } |
|
148 |
|
149 } |