public function testAddMetadatas() { $document = new Document(); $document->addMetadatas(array('foo' => 'bar')); $this->assertSame(array('foo' => 'bar'), $document->getMetadatas()); $document->addMetadatas(array('foo2' => 'bar2')); $this->assertSame(array('foo' => 'bar', 'foo2' => 'bar2'), $document->getMetadatas()); }
private function onPost(Document $document) { list($year, $month, $day, $slug) = explode('-', $document->getFile()->getBasename('.md'), 4); $document->addMetadatas(array('date' => new \DateTime("{$year}-{$month}-{$day}"))); $metadatas = $document->getMetadatas(); if (!isset($metadatas['permalink'])) { $path = strtr($this->permalinkFormat, array('%year%' => $year, '%month%' => $month, '%day%' => $day, '%slug%' => $slug)); $document->setPath($this->path->generatePath($path)); } }