/**
* 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;
}