Newscoop\Service\Template::cacheTemplates PHP Method

cacheTemplates() public method

public cacheTemplates ( $path )
    public function cacheTemplates($path)
    {
        try {
            $items = array();
            foreach ($this->storage->listItems($path) as $file) {
                $storageFile = $this->storage->getItem($file);
                if (!$storageFile->isDir() && $storageFile->getType() == 'tpl') {
                    $items[] = $this->repository->getTemplate($storageFile);
                }
            }
            return $this->repository->flush();
        } catch (\InvalidArgumentException $e) {
            throw new \InvalidArgumentException(sprintf("'%s' not found", $path), $e->getCode(), $e);
        }
    }

Usage Example

 public function cacheTemplatesAction()
 {
     $path = $this->parsePath();
     $this->service->cacheTemplates($path);
     $this->view->success = true;
 }