web/lib/Zend/Http/UserAgent/Storage/NonPersistent.php
changeset 64 162c1de6545a
parent 19 1c2f13fd785c
child 68 ecaf28ffe26e
equal deleted inserted replaced
63:5b37998e522e 64:162c1de6545a
       
     1 <?php
       
     2 /**
       
     3  * Zend Framework
       
     4  *
       
     5  * LICENSE
       
     6  *
       
     7  * This source file is subject to the new BSD license that is bundled
       
     8  * with this package in the file LICENSE.txt.
       
     9  * It is also available through the world-wide-web at this URL:
       
    10  * http://framework.zend.com/license/new-bsd
       
    11  * If you did not receive a copy of the license and are unable to
       
    12  * obtain it through the world-wide-web, please send an email
       
    13  * to license@zend.com so we can send you a copy immediately.
       
    14  *
       
    15  * @category   Zend
       
    16  * @package    Zend_Http
       
    17  * @subpackage UserAgent
       
    18  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
       
    19  * @license    http://framework.zend.com/license/new-bsd     New BSD License
       
    20  * @version    $Id: NonPersistent.php 20096 2010-01-06 02:05:09Z bkarwin $
       
    21  */
       
    22 
       
    23 
       
    24 /**
       
    25  * @see Zend_Http_UserAgent_Storage_Interface
       
    26  */
       
    27 require_once 'Zend/Http/UserAgent/Storage.php';
       
    28 
       
    29 
       
    30 /**
       
    31  * Non-Persistent Browser Storage
       
    32  *
       
    33  * Since HTTP Browserentication happens again on each request, this will always be
       
    34  * re-populated. So there's no need to use sessions, this simple value class
       
    35  * will hold the data for rest of the current request.
       
    36  *
       
    37  * @package    Zend_Http
       
    38  * @subpackage UserAgent
       
    39  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
       
    40  * @license    http://framework.zend.com/license/new-bsd     New BSD License
       
    41  */
       
    42 class Zend_Http_UserAgent_Storage_NonPersistent 
       
    43     implements Zend_Http_UserAgent_Storage
       
    44 {
       
    45     /**
       
    46      * Holds the actual Browser data
       
    47      * @var mixed
       
    48      */
       
    49     protected $_data;
       
    50 
       
    51     /**
       
    52      * Returns true if and only if storage is empty
       
    53      *
       
    54      * @throws Zend_Http_UserAgent_Storage_Exception If it is impossible to determine whether storage is empty
       
    55      * @return boolean
       
    56      */
       
    57     public function isEmpty()
       
    58     {
       
    59         return empty($this->_data);
       
    60     }
       
    61 
       
    62     /**
       
    63      * Returns the contents of storage
       
    64      *
       
    65      * Behavior is undefined when storage is empty.
       
    66      *
       
    67      * @throws Zend_Http_UserAgent_Storage_Exception If reading contents from storage is impossible
       
    68      * @return mixed
       
    69      */
       
    70     public function read()
       
    71     {
       
    72         return $this->_data;
       
    73     }
       
    74 
       
    75     /**
       
    76      * Writes $contents to storage
       
    77      *
       
    78      * @param  mixed $contents
       
    79      * @throws Zend_Http_UserAgent_Storage_Exception If writing $contents to storage is impossible
       
    80      * @return void
       
    81      */
       
    82     public function write($contents)
       
    83     {
       
    84         $this->_data = $contents;
       
    85     }
       
    86 
       
    87     /**
       
    88      * Clears contents from storage
       
    89      *
       
    90      * @throws Zend_Http_UserAgent_Storage_Exception If clearing contents from storage is impossible
       
    91      * @return void
       
    92      */
       
    93     public function clear()
       
    94     {
       
    95         $this->_data = null;
       
    96     }
       
    97 }