File indexing completed on 2024-06-16 05:30:08

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 Media
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_App_Extension
0026  */
0027 // require_once 'Zend/Gdata/App/Extension.php';
0028 
0029 /**
0030  * Represents the media:hash element
0031  *
0032  * @category   Zend
0033  * @package    Zend_Gdata
0034  * @subpackage Media
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_Media_Extension_MediaHash extends Zend_Gdata_Extension
0039 {
0040 
0041     protected $_rootElement = 'hash';
0042     protected $_rootNamespace = 'media';
0043     protected $_algo = null;
0044 
0045     /**
0046      * Constructs a new MediaHash element
0047      *
0048      * @param string $text
0049      * @param string $algo
0050      */
0051     public function __construct($text = null, $algo = null)
0052     {
0053         $this->registerAllNamespaces(Zend_Gdata_Media::$namespaces);
0054         parent::__construct();
0055         $this->_text = $text;
0056         $this->_algo = $algo;
0057     }
0058 
0059     /**
0060      * Retrieves a DOMElement which corresponds to this element and all
0061      * child properties.  This is used to build an entry back into a DOM
0062      * and eventually XML text for sending to the server upon updates, or
0063      * for application storage/persistence.
0064      *
0065      * @param DOMDocument $doc The DOMDocument used to construct DOMElements
0066      * @return DOMElement The DOMElement representing this element and all
0067      * child properties.
0068      */
0069     public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
0070     {
0071         $element = parent::getDOM($doc, $majorVersion, $minorVersion);
0072         if ($this->_algo !== null) {
0073             $element->setAttribute('algo', $this->_algo);
0074         }
0075         return $element;
0076     }
0077 
0078     /**
0079      * Given a DOMNode representing an attribute, tries to map the data into
0080      * instance members.  If no mapping is defined, the name and value are
0081      * stored in an array.
0082      *
0083      * @param DOMNode $attribute The DOMNode attribute needed to be handled
0084      * @throws Zend_Gdata_App_InvalidArgumentException
0085      */
0086     protected function takeAttributeFromDOM($attribute)
0087     {
0088         switch ($attribute->localName) {
0089         case 'algo':
0090             $this->_algo = $attribute->nodeValue;
0091             break;
0092         default:
0093             parent::takeAttributeFromDOM($attribute);
0094         }
0095     }
0096 
0097     /**
0098      * @return string The algo
0099      */
0100     public function getAlgo()
0101     {
0102         return $this->_algo;
0103     }
0104 
0105     /**
0106      * @param string $value
0107      * @return Zend_Gdata_Media_Extension_MediaHash Provides a fluent interface
0108      */
0109     public function setAlgo($value)
0110     {
0111         $this->_algo = $value;
0112         return $this;
0113     }
0114 
0115 }