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.
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
25 * @see Zend_Gdata_Extension
27 require_once 'Zend/Gdata/Extension.php';
30 * @see Zend_Gdata_Gapps
32 require_once 'Zend/Gdata/Gapps.php';
35 * Represents the apps:quota element used by the Apps data API. This is
36 * used to indicate the amount of storage space available to a user. Quotas
37 * may not be able to be set, depending on the domain used. This class
38 * is usually contained within an instance of Zend_Gdata_Gapps_UserEntry.
43 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
44 * @license http://framework.zend.com/license/new-bsd New BSD License
46 class Zend_Gdata_Gapps_Extension_Quota extends Zend_Gdata_Extension
49 protected $_rootNamespace = 'apps';
50 protected $_rootElement = 'quota';
53 * The amount of storage space available to the user in megabytes.
57 protected $_limit = null;
60 * Constructs a new Zend_Gdata_Gapps_Extension_Quota object.
62 * @param string $limit (optional) The limit, in bytes, for this quota.
64 public function __construct($limit = null)
66 $this->registerAllNamespaces(Zend_Gdata_Gapps::$namespaces);
67 parent::__construct();
68 $this->_limit = $limit;
72 * Retrieves a DOMElement which corresponds to this element and all
73 * child properties. This is used to build an entry back into a DOM
74 * and eventually XML text for sending to the server upon updates, or
75 * for application storage/persistence.
77 * @param DOMDocument $doc The DOMDocument used to construct DOMElements
78 * @return DOMElement The DOMElement representing this element and all
81 public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
83 $element = parent::getDOM($doc, $majorVersion, $minorVersion);
84 if ($this->_limit !== null) {
85 $element->setAttribute('limit', $this->_limit);
91 * Given a DOMNode representing an attribute, tries to map the data into
92 * instance members. If no mapping is defined, the name and value are
95 * @param DOMNode $attribute The DOMNode attribute needed to be handled
97 protected function takeAttributeFromDOM($attribute)
99 switch ($attribute->localName) {
101 $this->_limit = $attribute->nodeValue;
104 parent::takeAttributeFromDOM($attribute);
109 * Get the value for this element's limit attribute.
112 * @return string The requested attribute.
114 public function getLimit()
116 return $this->_limit;
120 * Set the value for this element's limit attribute. This is the amount
121 * of storage space, in bytes, that should be made available to
122 * the associated user.
124 * @param string $value The desired value for this attribute.
125 * @return Zend_Gdata_Gapps_Extension_Quota Provides a fluent interface.
127 public function setLimit($value)
129 $this->_limit = $value;
134 * Magic toString method allows using this directly via echo
135 * Works best in PHP >= 4.2.0
137 public function __toString()
139 return $this->getLimit();