Exemple #1
0
 /**
  * Convert item
  * 
  * @param ContentItemInterface $item
  * 
  * @return ContentItemInterface
  */
 public function convertItem(ContentItemInterface $item)
 {
     $extension = $item->getFileItem()->getExtension();
     $converter = $this->getConverter($extension);
     $outExtension = $converter->getOutExtension($extension);
     $content = $converter->convert($item->getPreConverterContent());
     $item->setPostConverterContent($content);
     $item->setOutExtension($outExtension);
     return new ConverterResult($content, $outExtension, get_class($converter));
 }
Exemple #2
0
 /**
  * @param ContentItemInterface $item
  *
  * @return string
  */
 private function getItemLayoutName(ContentItemInterface $item)
 {
     $layoutName = $item->getFrontmatter()->getFrontmatter()->get('layout');
     if ($layoutName) {
         if (false == is_string($layoutName)) {
             throw new FrontmatterValueException(sprintf('Invalid value.', $layoutName), 'layout', $item->getFileItem()->getFileName());
         }
         if (false == $this->existsLayout($layoutName)) {
             throw new FrontmatterValueException(sprintf('Layout "%s" not found.', $layoutName), 'layout', $item->getFileItem()->getFileName());
         }
         return $layoutName;
     } else {
         return '';
     }
 }
Exemple #3
0
 private function saveItem(ContentItemInterface $contentItem)
 {
     $item = $contentItem->getFileItem();
     $this->contentLocator->saveItem($item);
 }