Nette\Bridges\CacheLatte\CacheMacro::createCache PHP Method

createCache() public static method

Starts the output cache. Returns Nette\Caching\OutputHelper object if buffering was started.
public static createCache ( Nette\Caching\IStorage $cacheStorage, $key, &$parents, array $args = NULL ) : OutputHelper
$cacheStorage Nette\Caching\IStorage
$args array
return Nette\Caching\OutputHelper
    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;
    }