web/lib/Zend/Auth/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_Auth
       
    17  * @subpackage Storage
       
    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_Auth_Storage_Interface
       
    26  */
       
    27 require_once 'Zend/Auth/Storage/Interface.php';
       
    28 
       
    29 
       
    30 /**
       
    31  * Non-Persistent Auth Storage
       
    32  *
       
    33  * Since HTTP Authentication 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  * @category   Zend
       
    38  * @package    Zend_Auth
       
    39  * @subpackage Storage
       
    40  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
       
    41  * @license    http://framework.zend.com/license/new-bsd     New BSD License
       
    42  */
       
    43 class Zend_Auth_Storage_NonPersistent implements Zend_Auth_Storage_Interface
       
    44 {
       
    45     /**
       
    46      * Holds the actual auth data
       
    47      */
       
    48     protected $_data;
       
    49 
       
    50     /**
       
    51      * Returns true if and only if storage is empty
       
    52      *
       
    53      * @throws Zend_Auth_Storage_Exception If it is impossible to determine whether storage is empty
       
    54      * @return boolean
       
    55      */
       
    56     public function isEmpty()
       
    57     {
       
    58         return empty($this->_data);
       
    59     }
       
    60 
       
    61     /**
       
    62      * Returns the contents of storage
       
    63      * Behavior is undefined when storage is empty.
       
    64      *
       
    65      * @throws Zend_Auth_Storage_Exception If reading contents from storage is impossible
       
    66      * @return mixed
       
    67      */
       
    68     public function read()
       
    69     {
       
    70         return $this->_data;
       
    71     }
       
    72 
       
    73     /**
       
    74      * Writes $contents to storage
       
    75      *
       
    76      * @param  mixed $contents
       
    77      * @throws Zend_Auth_Storage_Exception If writing $contents to storage is impossible
       
    78      * @return void
       
    79      */
       
    80     public function write($contents)
       
    81     {
       
    82         $this->_data = $contents;
       
    83     }
       
    84 
       
    85     /**
       
    86      * Clears contents from storage
       
    87      *
       
    88      * @throws Zend_Auth_Storage_Exception If clearing contents from storage is impossible
       
    89      * @return void
       
    90      */
       
    91     public function clear()
       
    92     {
       
    93         $this->_data = null;
       
    94     }
       
    95 }