Refactoring to remove some duplication.

This commit is contained in:
mark_story 2010-11-09 22:27:36 -05:00
parent 1cf5e72054
commit 7ad4068085

View file

@ -334,18 +334,17 @@ class View extends Object {
} }
if (isset($params['cache'])) { if (isset($params['cache'])) {
if (is_array($params['cache'])) {
$defaults = array(
'config' => $this->elementCache,
'key' => $plugin . '_' . $name,
);
$caching = array_merge($defaults, $params['cache']);
} else {
$keys = array_merge(array($plugin, $name), array_keys($params)); $keys = array_merge(array($plugin, $name), array_keys($params));
$caching = array( $caching = array(
'config' => $this->elementCache, 'config' => $this->elementCache,
'key' => implode('_', $keys) 'key' => implode('_', $keys)
); );
if (is_array($params['cache'])) {
$defaults = array(
'config' => $this->elementCache,
'key' => $caching['key']
);
$caching = array_merge($defaults, $params['cache']);
} }
$key = 'element_' . $caching['key']; $key = 'element_' . $caching['key'];
$contents = Cache::read($key, $caching['config']); $contents = Cache::read($key, $caching['config']);