File indexing completed on 2025-03-02 05:29:27
0001 <?php 0002 0003 /** 0004 * Zend Framework 0005 * 0006 * LICENSE 0007 * 0008 * This source file is subject to the new BSD license that is bundled 0009 * with this package in the file LICENSE.txt. 0010 * It is also available through the world-wide-web at this URL: 0011 * http://framework.zend.com/license/new-bsd 0012 * If you did not receive a copy of the license and are unable to 0013 * obtain it through the world-wide-web, please send an email 0014 * to license@zend.com so we can send you a copy immediately. 0015 * 0016 * @category Zend 0017 * @package Zend_Gdata 0018 * @subpackage Gapps 0019 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0020 * @license http://framework.zend.com/license/new-bsd New BSD License 0021 * @version $Id$ 0022 */ 0023 0024 /** 0025 * @see Zend_Gdata_Extension 0026 */ 0027 // require_once 'Zend/Gdata/Extension.php'; 0028 0029 /** 0030 * @see Zend_Gdata_Gapps 0031 */ 0032 // require_once 'Zend/Gdata/Gapps.php'; 0033 0034 /** 0035 * Represents the apps:quota element used by the Apps data API. This is 0036 * used to indicate the amount of storage space available to a user. Quotas 0037 * may not be able to be set, depending on the domain used. This class 0038 * is usually contained within an instance of Zend_Gdata_Gapps_UserEntry. 0039 * 0040 * @category Zend 0041 * @package Zend_Gdata 0042 * @subpackage Gapps 0043 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0044 * @license http://framework.zend.com/license/new-bsd New BSD License 0045 */ 0046 class Zend_Gdata_Gapps_Extension_Quota extends Zend_Gdata_Extension 0047 { 0048 0049 protected $_rootNamespace = 'apps'; 0050 protected $_rootElement = 'quota'; 0051 0052 /** 0053 * The amount of storage space available to the user in megabytes. 0054 * 0055 * @var integer 0056 */ 0057 protected $_limit = null; 0058 0059 /** 0060 * Constructs a new Zend_Gdata_Gapps_Extension_Quota object. 0061 * 0062 * @param string $limit (optional) The limit, in bytes, for this quota. 0063 */ 0064 public function __construct($limit = null) 0065 { 0066 $this->registerAllNamespaces(Zend_Gdata_Gapps::$namespaces); 0067 parent::__construct(); 0068 $this->_limit = $limit; 0069 } 0070 0071 /** 0072 * Retrieves a DOMElement which corresponds to this element and all 0073 * child properties. This is used to build an entry back into a DOM 0074 * and eventually XML text for sending to the server upon updates, or 0075 * for application storage/persistence. 0076 * 0077 * @param DOMDocument $doc The DOMDocument used to construct DOMElements 0078 * @return DOMElement The DOMElement representing this element and all 0079 * child properties. 0080 */ 0081 public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null) 0082 { 0083 $element = parent::getDOM($doc, $majorVersion, $minorVersion); 0084 if ($this->_limit !== null) { 0085 $element->setAttribute('limit', $this->_limit); 0086 } 0087 return $element; 0088 } 0089 0090 /** 0091 * Given a DOMNode representing an attribute, tries to map the data into 0092 * instance members. If no mapping is defined, the name and value are 0093 * stored in an array. 0094 * 0095 * @param DOMNode $attribute The DOMNode attribute needed to be handled 0096 */ 0097 protected function takeAttributeFromDOM($attribute) 0098 { 0099 switch ($attribute->localName) { 0100 case 'limit': 0101 $this->_limit = $attribute->nodeValue; 0102 break; 0103 default: 0104 parent::takeAttributeFromDOM($attribute); 0105 } 0106 } 0107 0108 /** 0109 * Get the value for this element's limit attribute. 0110 * 0111 * @see setLimit 0112 * @return string The requested attribute. 0113 */ 0114 public function getLimit() 0115 { 0116 return $this->_limit; 0117 } 0118 0119 /** 0120 * Set the value for this element's limit attribute. This is the amount 0121 * of storage space, in bytes, that should be made available to 0122 * the associated user. 0123 * 0124 * @param string $value The desired value for this attribute. 0125 * @return Zend_Gdata_Gapps_Extension_Quota Provides a fluent interface. 0126 */ 0127 public function setLimit($value) 0128 { 0129 $this->_limit = $value; 0130 return $this; 0131 } 0132 0133 /** 0134 * Magic toString method allows using this directly via echo 0135 * Works best in PHP >= 4.2.0 0136 */ 0137 public function __toString() 0138 { 0139 return $this->getLimit(); 0140 } 0141 0142 }