/** * 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); }
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()); }
/** * Gets the relevant parser for a resource * * @param object $resource * @return object */ protected function getParser(Resource $resource) { return $this->parsers[$resource->getExtension()]; }