From f363b1063bc21bc99ba731debdef3866ef9630b7 Mon Sep 17 00:00:00 2001 From: Narno Date: Tue, 21 Mar 2017 00:58:15 +0100 Subject: [PATCH] Work with content. --- src/Step/LoadContent.php | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/src/Step/LoadContent.php b/src/Step/LoadContent.php index 029bad0..4db0047 100644 --- a/src/Step/LoadContent.php +++ b/src/Step/LoadContent.php @@ -9,6 +9,7 @@ namespace PHPoole\Step; use PHPoole\Exception\Exception; +use PHPoole\Util; use Symfony\Component\Finder\Finder; use Symfony\Component\Finder\SplFileInfo; @@ -49,6 +50,7 @@ public function internalProcess() /* @var $file SplFileInfo */ foreach ($files as $file) { $index = $file->getRelativePathname(); +<<<<<<< Updated upstream if (array_key_exists('frontmatter', $data)) { $fmProperties = $this->parse( $file->getContents(), @@ -59,16 +61,35 @@ public function internalProcess() $properties[$index]['id'] = $index; $properties[$index]['format'] = $format; $properties[$index]['lastmodified'] = $file->getMTime(); +======= + + $content[$index]['id'] = $index; + $content[$index]['filepath'] = $index; + $content[$index]['path'] = Util::urlize(trim($index, '.'.$format)); + + $content[$index]['format'] = $format; + $content[$index]['lastmodified'] = $file->getMTime(); + + // front matter? + if (isset($data['frontmatter'])) { + $content[$index] = array_merge($content[$index], $this->parseFM( + $file->getContents(), + $this->phpoole->getConfig()->get('content.frontmatter.'.$data['frontmatter'].'.parser') + )) ; + } +>>>>>>> Stashed changes } } + // DEBUG + //echo 'content:'.PHP_EOL; //print_r($content); $this->phpoole->setContent($properties); } /** - * Parse the contents of a file. + * Parse front matter of a file. * * Example: * ``` @@ -84,7 +105,7 @@ public function internalProcess() * * @return array */ - public function parse($content, $fmParser) + public function parseFM($content, $fmParser) { $properties = []; @@ -96,7 +117,7 @@ public function parse($content, $fmParser) ); // if not front matter, set 'content' property only if (!$matches) { - $properties['raw'] = $content; + $properties['content'] = $content; return $properties; } @@ -104,7 +125,7 @@ public function parse($content, $fmParser) /* @var $parser \PHPoole\Parser\ParserInterface */ $parser = new $fmParser(); $properties = $parser->parse(trim($matches[1])); - $properties['raw'] = trim($matches[2]); + $properties['content'] = trim($matches[2]); return $properties; }