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:nickname element used by the Apps data API. This 0036 * is used to describe a nickname's properties, and is usually contained 0037 * within instances of Zend_Gdata_Gapps_NicknameEntry. 0038 * 0039 * @category Zend 0040 * @package Zend_Gdata 0041 * @subpackage Gapps 0042 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0043 * @license http://framework.zend.com/license/new-bsd New BSD License 0044 */ 0045 class Zend_Gdata_Gapps_Extension_Nickname extends Zend_Gdata_Extension 0046 { 0047 0048 protected $_rootNamespace = 'apps'; 0049 protected $_rootElement = 'nickname'; 0050 0051 /** 0052 * The name of the nickname. This name is used as the email address 0053 * for this nickname. 0054 * 0055 * @var string 0056 */ 0057 protected $_name = null; 0058 0059 /** 0060 * Constructs a new Zend_Gdata_Gapps_Extension_Nickname object. 0061 * @param string $name (optional) The nickname being represented. 0062 */ 0063 public function __construct($name = null) 0064 { 0065 $this->registerAllNamespaces(Zend_Gdata_Gapps::$namespaces); 0066 parent::__construct(); 0067 $this->_name = $name; 0068 } 0069 0070 /** 0071 * Retrieves a DOMElement which corresponds to this element and all 0072 * child properties. This is used to build an entry back into a DOM 0073 * and eventually XML text for sending to the server upon updates, or 0074 * for application storage/persistence. 0075 * 0076 * @param DOMDocument $doc The DOMDocument used to construct DOMElements 0077 * @return DOMElement The DOMElement representing this element and all 0078 * child properties. 0079 */ 0080 public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null) 0081 { 0082 $element = parent::getDOM($doc, $majorVersion, $minorVersion); 0083 if ($this->_name !== null) { 0084 $element->setAttribute('name', $this->_name); 0085 } 0086 return $element; 0087 } 0088 0089 /** 0090 * Given a DOMNode representing an attribute, tries to map the data into 0091 * instance members. If no mapping is defined, the name and value are 0092 * stored in an array. 0093 * 0094 * @param DOMNode $attribute The DOMNode attribute needed to be handled 0095 */ 0096 protected function takeAttributeFromDOM($attribute) 0097 { 0098 switch ($attribute->localName) { 0099 case 'name': 0100 $this->_name = $attribute->nodeValue; 0101 break; 0102 default: 0103 parent::takeAttributeFromDOM($attribute); 0104 } 0105 } 0106 0107 /** 0108 * Get the value for this element's name attribute. 0109 * 0110 * @see setName 0111 * @return string The requested attribute. 0112 */ 0113 public function getName() 0114 { 0115 return $this->_name; 0116 } 0117 0118 /** 0119 * Set the value for this element's name attribute. This name uniquely 0120 * describes this nickname within the domain. Emails addressed to this 0121 * name will be delivered to the user who owns this nickname. 0122 * 0123 * @param string $value The desired value for this attribute. 0124 * @return Zend_Gdata_Gapps_Extension_Nickname Provides a fluent 0125 * interface. 0126 */ 0127 public function setName($value) 0128 { 0129 $this->_name = $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->getName(); 0140 } 0141 0142 }