Exemplo n.º 1
0
 /**
  * Calculates the metadata for a resource
  *
  * @param object $resource
  * @return array
  */
 public function getMetaData(Resource $resource)
 {
     if (!in_array($resource->getExtension(), $this->parsableExtensions)) {
         return array();
     }
     if (isset($this->registry[md5((string) $resource)])) {
         return $this->registry[md5((string) $resource)];
     }
     $frontMatter = new FrontMatter($resource);
     $matter = $this->normalizeCategories($resource, $frontMatter->getMatter());
     return $this->registry[md5((string) $resource)] = array('file' => (string) $resource, 'title' => $this->getTitle($resource, $matter), 'url' => $this->getUrl($resource, $matter), 'date' => $this->getDate($resource, $matter), 'stamp' => $this->getDate($resource, $matter, 'U'), 'namespace' => $this->getNamespace($resource, $matter), 'is_indexable' => isset($matter['indexable']) && !$matter['indexable'] || $resource->isIndexable(), 'matter' => $matter);
 }
Exemplo n.º 2
0
 protected function check($file)
 {
     $matter = new FrontMatter(new Resource($file));
     $m = $matter->getMatter();
     $c = $matter->getContents();
     $this->assertTrue(!empty($c));
     $this->assertTrue(!empty($m));
     $this->assertTrue(is_array($m));
     $this->assertTrue(isset($m['excerpt']));
     $this->assertTrue(isset($m['summary']));
     $this->assertTrue(is_array($m['category']));
 }