mirror of
https://github.com/retailcrm/PHPExcel.git
synced 2024-11-26 07:16:03 +03:00
Added a cacheMethodIsAvailable() method to all cell cache classes, making it easier to identify if all the necessary classes/functions are available for each caching option.
Renamed the factory getCacheStorageMethods() method to getAllCacheStorageMethods(), returning all cache options in the library. Wrote a new factory getCacheStorageMethods() method to return an array of those cache methods that are available with the current build of PHP (extensions tested, etc). Refactored factory initialize() method to use the cacheMethodIsAvailable(), so factoring the logic for testing methods out of the factory. git-svn-id: https://phpexcel.svn.codeplex.com/svn/trunk@83741 2327b42d-5241-43d6-9e2a-de5ac946f064
This commit is contained in:
parent
93e8a05780
commit
cd7f0a1c51
@ -219,4 +219,22 @@ class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_Cach
|
|||||||
}
|
}
|
||||||
} // function __destruct()
|
} // function __destruct()
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Identify whether the caching method is currently available
|
||||||
|
* Some methods are dependent on the availability of certain extensions being enabled in the PHP build
|
||||||
|
*
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public static function cacheMethodIsAvailable() {
|
||||||
|
if (!function_exists('apc_store')) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (apc_sma_info() === false) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -176,4 +176,15 @@ class PHPExcel_CachedObjectStorage_CacheBase {
|
|||||||
}
|
}
|
||||||
} // function copyCellCollection()
|
} // function copyCellCollection()
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Identify whether the caching method is currently available
|
||||||
|
* Some methods are dependent on the availability of certain extensions being enabled in the PHP build
|
||||||
|
*
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public static function cacheMethodIsAvailable() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -101,4 +101,12 @@ interface PHPExcel_CachedObjectStorage_ICache
|
|||||||
*/
|
*/
|
||||||
public function copyCellCollection(PHPExcel_Worksheet $parent);
|
public function copyCellCollection(PHPExcel_Worksheet $parent);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Identify whether the caching method is currently available
|
||||||
|
* Some methods are dependent on the availability of certain extensions being enabled in the PHP build
|
||||||
|
*
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public static function cacheMethodIsAvailable();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -108,4 +108,19 @@ class PHPExcel_CachedObjectStorage_Igbinary extends PHPExcel_CachedObjectStorage
|
|||||||
$this->_parent = null;
|
$this->_parent = null;
|
||||||
} // function unsetWorksheetCells()
|
} // function unsetWorksheetCells()
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Identify whether the caching method is currently available
|
||||||
|
* Some methods are dependent on the availability of certain extensions being enabled in the PHP build
|
||||||
|
*
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public static function cacheMethodIsAvailable() {
|
||||||
|
if (!function_exists('igbinary_serialize')) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -237,4 +237,18 @@ class PHPExcel_CachedObjectStorage_Memcache extends PHPExcel_CachedObjectStorage
|
|||||||
}
|
}
|
||||||
} // function __destruct()
|
} // function __destruct()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Identify whether the caching method is currently available
|
||||||
|
* Some methods are dependent on the availability of certain extensions being enabled in the PHP build
|
||||||
|
*
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public static function cacheMethodIsAvailable() {
|
||||||
|
if (!function_exists('memcache_add')) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -220,4 +220,19 @@ class PHPExcel_CachedObjectStorage_SQLite extends PHPExcel_CachedObjectStorage_C
|
|||||||
$this->_DBHandle = null;
|
$this->_DBHandle = null;
|
||||||
} // function __destruct()
|
} // function __destruct()
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Identify whether the caching method is currently available
|
||||||
|
* Some methods are dependent on the availability of certain extensions being enabled in the PHP build
|
||||||
|
*
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public static function cacheMethodIsAvailable() {
|
||||||
|
if (!function_exists('sqlite_open')) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -227,4 +227,19 @@ class PHPExcel_CachedObjectStorage_SQLite3 extends PHPExcel_CachedObjectStorage_
|
|||||||
$this->_DBHandle = null;
|
$this->_DBHandle = null;
|
||||||
} // function __destruct()
|
} // function __destruct()
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Identify whether the caching method is currently available
|
||||||
|
* Some methods are dependent on the availability of certain extensions being enabled in the PHP build
|
||||||
|
*
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public static function cacheMethodIsAvailable() {
|
||||||
|
if (!class_exists('SQLite3')) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -231,4 +231,19 @@ class PHPExcel_CachedObjectStorage_Wincache extends PHPExcel_CachedObjectStorage
|
|||||||
}
|
}
|
||||||
} // function __destruct()
|
} // function __destruct()
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Identify whether the caching method is currently available
|
||||||
|
* Some methods are dependent on the availability of certain extensions being enabled in the PHP build
|
||||||
|
*
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public static function cacheMethodIsAvailable() {
|
||||||
|
if (!function_exists('wincache_ucache_add')) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -81,51 +81,32 @@ class PHPExcel_CachedObjectStorageFactory {
|
|||||||
} // function getCacheStorageClass()
|
} // function getCacheStorageClass()
|
||||||
|
|
||||||
|
|
||||||
public static function getCacheStorageMethods() {
|
public static function getAllCacheStorageMethods() {
|
||||||
return self::$_storageMethods;
|
return self::$_storageMethods;
|
||||||
} // function getCacheStorageMethods()
|
} // function getCacheStorageMethods()
|
||||||
|
|
||||||
|
|
||||||
|
public static function getCacheStorageMethods() {
|
||||||
|
$activeMethods = array();
|
||||||
|
foreach(self::$_storageMethods as $storageMethod) {
|
||||||
|
$cacheStorageClass = 'PHPExcel_CachedObjectStorage_'.$storageMethod;
|
||||||
|
if (call_user_func(array($cacheStorageClass,'cacheMethodIsAvailable'))) {
|
||||||
|
$activeMethods[] = $storageMethod;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $activeMethods;
|
||||||
|
} // function getCacheStorageMethods()
|
||||||
|
|
||||||
|
|
||||||
public static function initialize($method = self::cache_in_memory, $arguments = array()) {
|
public static function initialize($method = self::cache_in_memory, $arguments = array()) {
|
||||||
if (!in_array($method,self::$_storageMethods)) {
|
if (!in_array($method,self::$_storageMethods)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch($method) {
|
$cacheStorageClass = 'PHPExcel_CachedObjectStorage_'.$method;
|
||||||
case self::cache_to_apc :
|
if (!call_user_func(array($cacheStorageClass,'cacheMethodIsAvailable'))) {
|
||||||
if (!function_exists('apc_store')) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (apc_sma_info() === false) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case self::cache_to_memcache :
|
|
||||||
if (!function_exists('memcache_add')) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case self::cache_to_wincache :
|
|
||||||
if (!function_exists('wincache_ucache_add')) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case self::cache_to_sqlite :
|
|
||||||
if (!function_exists('sqlite_open')) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case self::cache_to_sqlite3 :
|
|
||||||
if (!class_exists('SQLite3')) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case self::cache_igbinary :
|
|
||||||
if (!function_exists('igbinary_serialize')) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
self::$_storageMethodParameters[$method] = self::$_storageMethodDefaultParameters[$method];
|
self::$_storageMethodParameters[$method] = self::$_storageMethodDefaultParameters[$method];
|
||||||
foreach($arguments as $k => $v) {
|
foreach($arguments as $k => $v) {
|
||||||
|
Loading…
Reference in New Issue
Block a user