コード例 #1
0
 /**
  * @param array $data
  *
  * @return FrontMatter
  */
 public function transform(array $data)
 {
     $frontMatter = new FrontMatter();
     foreach ($data as $key => $value) {
         if ($taxonomy = $this->getTaxonomyByKey($key)) {
             $terms = $this->getTerms($taxonomy, $value);
             $frontMatter->addTerms($terms);
         }
         if ($isProperty = $this->keyIsFrontMatterProperty($frontMatter, $key)) {
             $setter = 'set' . ucfirst($key);
             if ('date' === $key) {
                 $value = $this->convertToDateTime($value);
             }
             $frontMatter->{$setter}($value);
         }
         # Metadata is arbitrary data an author wants
         # to have available in the view as a variable.
         $isMetadata = is_null($taxonomy) && false === $isProperty;
         if ($isMetadata) {
             $frontMatter->setMeta($key, $value);
         }
     }
     return $frontMatter;
 }
コード例 #2
0
 /**
  * @return ArrayCollection
  */
 public function getMetadata()
 {
     return $this->frontMatter->getAllMetadata();
 }