Skip to content

Commit

Permalink
Allowing custom options to be specified in the config file
Browse files Browse the repository at this point in the history
  • Loading branch information
dragoonis committed Nov 27, 2011
1 parent 5376aad commit 523c0d8
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions PPI/Core.php
Expand Up @@ -59,15 +59,19 @@ static function getSession($options = null) {
* @param null $options
* @return Cache
*/
static function getCache($options = null) {

if (!is_array($options)) {
$config = Registry::get('PPI_Config');
$options = isset($config->cache) ? $config->cache->toArray() : array();
if (is_string($options) && $options !== '') {
$options['handler'] = $options;
static function getCache(array $options = array()) {

if(!isset($options['handler'])) {
$config = Registry::get('PPI_Config');
$cacheOptions = isset($config->cache) ? $config->cache->toArray() : array();
if(isset($cacheOptions['options'])) {
$cacheOptions = ($cacheOptions + $cacheOptions['options']->toArray());
unset($cacheOptions['options']);
}
$options = $options;
$options = ($options + $cacheOptions);
}
if(!isset($options['handler'])) {
$options['handler'] = 'disk';
}
return new Cache($options);
}
Expand Down

0 comments on commit 523c0d8

Please sign in to comment.