[ Index ]

PHP Cross Reference of moodle-2.8

title

Body

[close]

/lib/zend/Zend/Gdata/Gapps/Extension/ -> Name.php (source)

   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 [email protected] 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$
  22   */
  23  
  24  /**
  25   * @see Zend_Gdata_Extension
  26   */
  27  require_once 'Zend/Gdata/Extension.php';
  28  
  29  /**
  30   * @see Zend_Gdata_Gapps
  31   */
  32  require_once 'Zend/Gdata/Gapps.php';
  33  
  34  /**
  35   * Represents the apps:name element used by the Apps data API. This is used
  36   * to represent a user's full name. This class is usually contained within
  37   * instances of Zend_Gdata_Gapps_UserEntry.
  38   *
  39   * @category   Zend
  40   * @package    Zend_Gdata
  41   * @subpackage Gapps
  42   * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
  43   * @license    http://framework.zend.com/license/new-bsd     New BSD License
  44   */
  45  class Zend_Gdata_Gapps_Extension_Name extends Zend_Gdata_Extension
  46  {
  47  
  48      protected $_rootNamespace = 'apps';
  49      protected $_rootElement = 'name';
  50  
  51      /**
  52       * The associated user's family name.
  53       *
  54       * @var string
  55       */
  56      protected $_familyName = null;
  57  
  58      /**
  59       * The associated user's given name.
  60       *
  61       * @var string
  62       */
  63      protected $_givenName = null;
  64  
  65      /**
  66       * Constructs a new Zend_Gdata_Gapps_Extension_Name object.
  67       *
  68       * @param string $familyName (optional) The familyName to be set for this
  69       *          object.
  70       * @param string $givenName (optional) The givenName to be set for this
  71       *          object.
  72       */
  73      public function __construct($familyName = null, $givenName = null)
  74      {
  75          $this->registerAllNamespaces(Zend_Gdata_Gapps::$namespaces);
  76          parent::__construct();
  77          $this->_familyName = $familyName;
  78          $this->_givenName = $givenName;
  79      }
  80  
  81      /**
  82       * Retrieves a DOMElement which corresponds to this element and all
  83       * child properties.  This is used to build an entry back into a DOM
  84       * and eventually XML text for sending to the server upon updates, or
  85       * for application storage/persistence.
  86       *
  87       * @param DOMDocument $doc The DOMDocument used to construct DOMElements
  88       * @return DOMElement The DOMElement representing this element and all
  89       * child properties.
  90       */
  91      public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
  92      {
  93          $element = parent::getDOM($doc, $majorVersion, $minorVersion);
  94          if ($this->_familyName !== null) {
  95              $element->setAttribute('familyName', $this->_familyName);
  96          }
  97          if ($this->_givenName !== null) {
  98              $element->setAttribute('givenName', $this->_givenName);
  99          }
 100          return $element;
 101      }
 102  
 103      /**
 104       * Given a DOMNode representing an attribute, tries to map the data into
 105       * instance members.  If no mapping is defined, the name and value are
 106       * stored in an array.
 107       *
 108       * @param DOMNode $attribute The DOMNode attribute needed to be handled
 109       */
 110      protected function takeAttributeFromDOM($attribute)
 111      {
 112          switch ($attribute->localName) {
 113          case 'familyName':
 114              $this->_familyName = $attribute->nodeValue;
 115              break;
 116          case 'givenName':
 117              $this->_givenName = $attribute->nodeValue;
 118              break;
 119          default:
 120              parent::takeAttributeFromDOM($attribute);
 121          }
 122      }
 123  
 124      /**
 125       * Get the value for this element's familyName attribute.
 126       *
 127       * @see setFamilyName
 128       * @return string The requested attribute.
 129       */
 130      public function getFamilyName()
 131      {
 132          return $this->_familyName;
 133      }
 134  
 135      /**
 136       * Set the value for this element's familyName attribute. This
 137       * represents a user's family name.
 138       *
 139       * @param string $value The desired value for this attribute.
 140       * @return Zend_Gdata_Gapps_Extension_Name Provides a fluent interface..
 141       */
 142      public function setFamilyName($value)
 143      {
 144          $this->_familyName = $value;
 145          return $this;
 146      }
 147  
 148      /**
 149       * Get the value for this element's givenName attribute.
 150       *
 151       * @see setGivenName
 152       * @return string The requested attribute.
 153       */
 154      public function getGivenName()
 155      {
 156          return $this->_givenName;
 157      }
 158  
 159      /**
 160       * Set the value for this element's givenName attribute. This
 161       * represents a user's given name.
 162       *
 163       * @param string $value The desired value for this attribute.
 164       * @return Zend_Gdata_Gapps_Extension_Name Provides a fluent interface.
 165       */
 166      public function setGivenName($value)
 167      {
 168          $this->_givenName = $value;
 169          return $this;
 170      }
 171  
 172      /**
 173       * Magic toString method allows using this directly via echo
 174       * Works best in PHP >= 4.2.0
 175       */
 176      public function __toString()
 177      {
 178          return $this->getGivenName() . ' ' . $this->getFamilyName();
 179      }
 180  
 181  }


Generated: Fri Nov 28 20:29:05 2014 Cross-referenced by PHPXref 0.7.1