getTemplate() public method

Get template for given key
public getTemplate ( string $key ) : Template
$key string
return Newscoop\Entity\Template
Example #1
0
 /**
  * Fetch item metadata
  *
  * @param string $key
  * @return object
  */
 public function fetchMetadata($key)
 {
     $item = $this->storage->getItem($key);
     $metadata = array('key' => $item->getKey(), 'name' => $item->getName(), 'type' => $item->getType(), 'realpath' => $this->storage->getRealpath($key));
     if (!$item->isDir()) {
         $metadata += array('size' => $item->getSize(), 'ctime' => $item->getChangeTime());
         if ($metadata['type'] == 'tpl') {
             $template = $this->repository->getTemplate($key, false);
             // get the resource for the template id
             $resource = $this->syncResServ->findByPathOrId(rtrim($this->theme->getPath(), "/") . "/" . ltrim($key, "/"));
             /* @var $resource Newscoop\Entity\Resource */
             $metadata += array('id' => is_object($resource) ? $resource->getId() : $template->getId(), 'ttl' => $template->getCacheLifetime());
         }
     }
     return (object) $metadata;
 }
Example #2
0
 /**
  * Implements Iterator::current
  *
  * @return Newscoop\Entity\Template
  */
 public function current()
 {
     $file = new \SplFileObject(current($this->files));
     return $this->repository->getTemplate($file, $this->root);
 }