/** * 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)); }
/** * @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 ''; } }
private function saveItem(ContentItemInterface $contentItem) { $item = $contentItem->getFileItem(); $this->contentLocator->saveItem($item); }