File indexing completed on 2024-06-23 05:55:21

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 Calendar
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  * Data model class to represent an entry's sendEventNotifications
0031  *
0032  * @category   Zend
0033  * @package    Zend_Gdata
0034  * @subpackage Calendar
0035  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0036  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0037  */
0038 class Zend_Gdata_Calendar_Extension_SendEventNotifications extends Zend_Gdata_Extension
0039 {
0040     protected $_rootNamespace = 'gCal';
0041     protected $_rootElement = 'sendEventNotifications';
0042     protected $_value = null;
0043 
0044     /**
0045      * Constructs a new Zend_Gdata_Extension_SendEventNotifications object.
0046      * @param bool $value (optional) SendEventNotifications value as URI.
0047      */
0048     public function __construct($value = null)
0049     {
0050         $this->registerAllNamespaces(Zend_Gdata_Calendar::$namespaces);
0051         parent::__construct();
0052         $this->_value = $value;
0053     }
0054 
0055     /**
0056      * Retrieves a DOMElement which corresponds to this element and all
0057      * child properties.  This is used to build an entry back into a DOM
0058      * and eventually XML text for sending to the server upon updates, or
0059      * for application storage/persistence.
0060      *
0061      * @param DOMDocument $doc The DOMDocument used to construct DOMElements
0062      * @return DOMElement The DOMElement representing this element and all
0063      * child properties.
0064      */
0065     public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
0066     {
0067         $element = parent::getDOM($doc, $majorVersion, $minorVersion);
0068         if ($this->_value !== null) {
0069             $element->setAttribute('value', ($this->_value ? "true" : "false"));
0070         }
0071         return $element;
0072     }
0073 
0074     /**
0075      * Given a DOMNode representing an attribute, tries to map the data into
0076      * instance members.  If no mapping is defined, the name and value are
0077      * stored in an array.
0078      *
0079      * @param DOMNode $attribute The DOMNode attribute needed to be handled
0080      */
0081     protected function takeAttributeFromDOM($attribute)
0082     {
0083         switch ($attribute->localName) {
0084         case 'value':
0085             if ($attribute->nodeValue == "true") {
0086                 $this->_value = true;
0087             }
0088             else if ($attribute->nodeValue == "false") {
0089                 $this->_value = false;
0090             }
0091             else {
0092                 throw new Zend_Gdata_App_InvalidArgumentException("Expected 'true' or 'false' for gCal:selected#value.");
0093             }
0094             break;
0095         default:
0096             parent::takeAttributeFromDOM($attribute);
0097         }
0098     }
0099 
0100     /**
0101      * Get the value for this element's Value attribute.
0102      *
0103      * @return string The requested attribute.
0104      */
0105     public function getValue()
0106     {
0107         return $this->_value;
0108     }
0109 
0110     /**
0111      * Set the value for this element's Value attribute.
0112      *
0113      * @param string $value The desired value for this attribute.
0114      * @return Zend_Gdata_Extension_SendEventNotifications The element being modified.
0115      */
0116     public function setValue($value)
0117     {
0118         $this->_value = $value;
0119         return $this;
0120     }
0121 
0122     /**
0123      * Magic toString method allows using this directly via echo
0124      * Works best in PHP >= 4.2.0
0125      */
0126     public function __toString()
0127     {
0128         return $this->getValue();
0129     }
0130 
0131 }
0132