web/lib/Zend/Gdata/Gapps/NicknameEntry.php
changeset 64 162c1de6545a
parent 19 1c2f13fd785c
child 68 ecaf28ffe26e
equal deleted inserted replaced
63:5b37998e522e 64:162c1de6545a
       
     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 Gapps
       
    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: NicknameEntry.php 20096 2010-01-06 02:05:09Z bkarwin $
       
    22  */
       
    23 
       
    24 /**
       
    25  * @see Zend_Gdata_Entry
       
    26  */
       
    27 require_once 'Zend/Gdata/Entry.php';
       
    28 
       
    29 /**
       
    30  * @see Zend_Gdata_Gapps_Extension_Login
       
    31  */
       
    32 require_once 'Zend/Gdata/Gapps/Extension/Login.php';
       
    33 
       
    34 /**
       
    35  * @see Zend_Gdata_Gapps_Extension_Nickname
       
    36  */
       
    37 require_once 'Zend/Gdata/Gapps/Extension/Nickname.php';
       
    38 
       
    39 /**
       
    40  * Data model class for a Google Apps Nickname Entry.
       
    41  *
       
    42  * Each nickname entry describes a single nickname within a Google Apps
       
    43  * hosted domain. Each user may own several nicknames, but each nickname may
       
    44  * only belong to one user. Multiple entries are contained within instances
       
    45  * of Zend_Gdata_Gapps_NicknameFeed.
       
    46  *
       
    47  * To transfer nickname entries to and from the Google Apps servers,
       
    48  * including creating new entries, refer to the Google Apps service class,
       
    49  * Zend_Gdata_Gapps.
       
    50  *
       
    51  * This class represents <atom:entry> in the Google Data protocol.
       
    52  *
       
    53  * @category   Zend
       
    54  * @package    Zend_Gdata
       
    55  * @subpackage Gapps
       
    56  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
       
    57  * @license    http://framework.zend.com/license/new-bsd     New BSD License
       
    58  */
       
    59 class Zend_Gdata_Gapps_NicknameEntry extends Zend_Gdata_Entry
       
    60 {
       
    61 
       
    62     protected $_entryClassName = 'Zend_Gdata_Gapps_NicknameEntry';
       
    63 
       
    64     /**
       
    65      * <apps:login> element used to hold information about the owner
       
    66      * of this nickname, including their username.
       
    67      *
       
    68      * @var Zend_Gdata_Gapps_Extension_Login
       
    69      */
       
    70     protected $_login = null;
       
    71 
       
    72     /**
       
    73      * <apps:nickname> element used to hold the name of this nickname.
       
    74      *
       
    75      * @var Zend_Gdata_Gapps_Extension_Nickname
       
    76      */
       
    77     protected $_nickname = null;
       
    78 
       
    79     /**
       
    80      * Create a new instance.
       
    81      *
       
    82      * @param DOMElement $element (optional) DOMElement from which this
       
    83      *          object should be constructed.
       
    84      */
       
    85     public function __construct($element = null)
       
    86     {
       
    87         $this->registerAllNamespaces(Zend_Gdata_Gapps::$namespaces);
       
    88         parent::__construct($element);
       
    89     }
       
    90 
       
    91     /**
       
    92      * Retrieves a DOMElement which corresponds to this element and all
       
    93      * child properties.  This is used to build an entry back into a DOM
       
    94      * and eventually XML text for application storage/persistence.
       
    95      *
       
    96      * @param DOMDocument $doc The DOMDocument used to construct DOMElements
       
    97      * @return DOMElement The DOMElement representing this element and all
       
    98      *          child properties.
       
    99      */
       
   100     public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
       
   101     {
       
   102         $element = parent::getDOM($doc, $majorVersion, $minorVersion);
       
   103         if ($this->_login !== null) {
       
   104             $element->appendChild($this->_login->getDOM($element->ownerDocument));
       
   105         }
       
   106         if ($this->_nickname !== null) {
       
   107             $element->appendChild($this->_nickname->getDOM($element->ownerDocument));
       
   108         }
       
   109         return $element;
       
   110     }
       
   111 
       
   112     /**
       
   113      * Creates individual Entry objects of the appropriate type and
       
   114      * stores them as members of this entry based upon DOM data.
       
   115      *
       
   116      * @param DOMNode $child The DOMNode to process
       
   117      */
       
   118     protected function takeChildFromDOM($child)
       
   119     {
       
   120         $absoluteNodeName = $child->namespaceURI . ':' . $child->localName;
       
   121 
       
   122         switch ($absoluteNodeName) {
       
   123             case $this->lookupNamespace('apps') . ':' . 'login';
       
   124                 $login = new Zend_Gdata_Gapps_Extension_Login();
       
   125                 $login->transferFromDOM($child);
       
   126                 $this->_login = $login;
       
   127                 break;
       
   128             case $this->lookupNamespace('apps') . ':' . 'nickname';
       
   129                 $nickname = new Zend_Gdata_Gapps_Extension_Nickname();
       
   130                 $nickname->transferFromDOM($child);
       
   131                 $this->_nickname = $nickname;
       
   132                 break;
       
   133             default:
       
   134                 parent::takeChildFromDOM($child);
       
   135                 break;
       
   136         }
       
   137     }
       
   138 
       
   139     /**
       
   140      * Get the value of the login property for this object.
       
   141      *
       
   142      * @see setLogin
       
   143      * @return Zend_Gdata_Gapps_Extension_Login The requested object.
       
   144      */
       
   145     public function getLogin()
       
   146     {
       
   147         return $this->_login;
       
   148     }
       
   149 
       
   150     /**
       
   151      * Set the value of the login property for this object. This property
       
   152      * is used to store the username address of the current user.
       
   153      *
       
   154      * @param Zend_Gdata_Gapps_Extension_Login $value The desired value for
       
   155      *          this instance's login property.
       
   156      * @return Zend_Gdata_Gapps_NicknameEntry Provides a fluent interface.
       
   157      */
       
   158     public function setLogin($value)
       
   159     {
       
   160         $this->_login = $value;
       
   161         return $this;
       
   162     }
       
   163 
       
   164     /**
       
   165      * Get the value of the nickname property for this object.
       
   166      *
       
   167      * @see setNickname
       
   168      * @return Zend_Gdata_Gapps_Extension_Nickname The requested object.
       
   169      */
       
   170     public function getNickname()
       
   171     {
       
   172         return $this->_nickname;
       
   173     }
       
   174 
       
   175     /**
       
   176      * Set the value of the nickname property for this object. This property
       
   177      * is used to store the the name of the current nickname.
       
   178      *
       
   179      * @param Zend_Gdata_Gapps_Extension_Nickname $value The desired value for
       
   180      *          this instance's nickname property.
       
   181      * @return Zend_Gdata_Gapps_NicknameEntry Provides a fluent interface.
       
   182      */
       
   183     public function setNickname($value)
       
   184     {
       
   185         $this->_nickname = $value;
       
   186         return $this;
       
   187     }
       
   188 
       
   189 }