예제 #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);
 }
예제 #2
0
 public function testDirectory()
 {
     $file = RESOURCE_DIR . '/';
     $relative = str_replace(__DIR__, '', $file);
     $resource = new Resource($file, $relative);
     $this->assertEquals('', $resource->getExtension());
     $this->assertEquals(rtrim($relative, '/'), $resource->getRelativePath());
     $this->assertEquals(rtrim($relative, '/'), $resource->getRelativePath(true));
     $this->assertFalse($resource->isIndexable());
     $this->assertEquals(basename($file), $resource->getFilenameShort(true));
     $this->assertEquals(basename($file), $resource->getFilenameShort(false));
     $this->assertEmpty($resource->getContents());
 }
예제 #3
0
 /**
  * Gets the relevant parser for a resource
  *
  * @param object $resource
  * @return object
  */
 protected function getParser(Resource $resource)
 {
     return $this->parsers[$resource->getExtension()];
 }