public static function createCache(Nette\Caching\IStorage $cacheStorage, $key, &$parents, array $args = NULL)
{
if ($args) {
if (array_key_exists('if', $args) && !$args['if']) {
return $parents[] = new \stdClass();
}
$key = array_merge([$key], array_intersect_key($args, range(0, count($args))));
}
if ($parents) {
end($parents)->dependencies[Cache::ITEMS][] = $key;
}
$cache = new Cache($cacheStorage, 'Nette.Templating.Cache');
if ($helper = $cache->start($key)) {
if (isset($args['dependencies'])) {
$args += call_user_func($args['dependencies']);
}
if (isset($args['expire'])) {
$args['expiration'] = $args['expire'];
// back compatibility
}
$helper->dependencies = [$cache::TAGS => isset($args['tags']) ? $args['tags'] : NULL, $cache::EXPIRATION => isset($args['expiration']) ? $args['expiration'] : '+ 7 days'];
$parents[] = $helper;
}
return $helper;
}