File indexing completed on 2025-01-19 05:21:35
0001 <?php 0002 /** 0003 * Zend Framework 0004 * 0005 * LICENSE 0006 * 0007 * This source file is subject to the new BSD license that is bundled 0008 * with this package in the file LICENSE.txt. 0009 * It is also available through the world-wide-web at this URL: 0010 * http://framework.zend.com/license/new-bsd 0011 * If you did not receive a copy of the license and are unable to 0012 * obtain it through the world-wide-web, please send an email 0013 * to license@zend.com so we can send you a copy immediately. 0014 * 0015 * @category Zend 0016 * @package Zend_Tool 0017 * @subpackage Framework 0018 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0019 * @license http://framework.zend.com/license/new-bsd New BSD License 0020 * @version $Id$ 0021 */ 0022 0023 /** 0024 * @see Zend_Tool_Framework_Client_Storage_AdapterInterface 0025 */ 0026 // require_once 'Zend/Tool/Framework/Client/Storage/AdapterInterface.php'; 0027 0028 /** 0029 * @category Zend 0030 * @package Zend_Tool 0031 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0032 * @license http://framework.zend.com/license/new-bsd New BSD License 0033 */ 0034 class Zend_Tool_Framework_Client_Storage 0035 { 0036 0037 /** 0038 * @var Zend_Tool_Framework_Client_Storage_AdapterInterface 0039 */ 0040 protected $_adapter = null; 0041 0042 public function __construct($options = array()) 0043 { 0044 if (isset($options['adapter'])) { 0045 $this->setAdapter($options['adapter']); 0046 } 0047 } 0048 0049 public function setAdapter($adapter) 0050 { 0051 if (is_string($adapter)) { 0052 $storageAdapterClass = 'Zend_Tool_Framework_Client_Storage_' . ucfirst($adapter); 0053 Zend_Loader::loadClass($storageAdapterClass); 0054 $adapter = new $storageAdapterClass(); 0055 } 0056 $this->_adapter = $adapter; 0057 } 0058 0059 public function isEnabled() 0060 { 0061 return ($this->_adapter instanceof Zend_Tool_Framework_Client_Storage_AdapterInterface); 0062 } 0063 0064 public function put($name, $value) 0065 { 0066 if (!$this->_adapter) { 0067 return false; 0068 } 0069 0070 $this->_adapter->put($name, $value); 0071 0072 return $this; 0073 } 0074 0075 public function get($name, $defaultValue = false) 0076 { 0077 if (!$this->_adapter) { 0078 return false; 0079 } 0080 0081 if ($this->_adapter->has($name)) { 0082 return $this->_adapter->get($name); 0083 } else { 0084 return $defaultValue; 0085 } 0086 0087 } 0088 0089 public function has($name) 0090 { 0091 if (!$this->_adapter) { 0092 return false; 0093 } 0094 0095 return $this->_adapter->has($name); 0096 } 0097 0098 public function remove($name) 0099 { 0100 if (!$this->_adapter) { 0101 return false; 0102 } 0103 0104 $this->_adapter->remove($name); 0105 0106 return $this; 0107 } 0108 0109 public function getStreamUri($name) 0110 { 0111 if (!$this->_adapter) { 0112 return false; 0113 } 0114 0115 return $this->_adapter->getStreamUri($name); 0116 } 0117 }