Add getPureContent to Page to be able to get content without template

This commit is contained in:
Stéphane Goetz 2016-03-13 21:51:15 +01:00
bovenliggende d8f7a6e238
commit 55ef0b982b
7 gewijzigde bestanden met toevoegingen van 38 en 5 verwijderingen

Bestand weergeven

@ -15,4 +15,9 @@ abstract class ComputedRawPage implements Page
{
return $this->raw->getContent();
}
public function getPureContent()
{
return $this->raw->getContent();
}
}

Bestand weergeven

@ -21,6 +21,8 @@ abstract class ContentPage extends SimplePage
*/
protected $contentType;
protected $generatedContent;
public function __construct($title, $content)
{
$this->initializePage($title, $content);
@ -49,14 +51,18 @@ abstract class ContentPage extends SimplePage
$this->contentType = $contentType;
}
protected function convertPage($content)
public function getPureContent()
{
return $this->contentType->convert($content, $this->getFile());
if (!$this->generatedContent) {
$this->generatedContent = $this->contentType->convert($this->content, $this->getFile());
}
return $this->generatedContent;
}
protected function generatePage()
{
return $this->convertPage($this->content);
return $this->getPureContent();
}
public static function fromFile(Content $file, $params, ContentType $contentType)

Bestand weergeven

@ -2,5 +2,17 @@
interface Page
{
/**
* Get the converted content, without any template
*
* @return string
*/
public function getPureContent();
/**
* Get the full content
*
* @return mixed
*/
public function getContent();
}

Bestand weergeven

@ -16,6 +16,11 @@ abstract class RawPage implements Page
return $this->file;
}
public function getPureContent()
{
throw new Exception("you should not use this method to show a raw content");
}
public function getContent()
{
throw new Exception("you should not use this method to show a raw content");

Bestand weergeven

@ -11,6 +11,11 @@ abstract class SimplePage implements Page
$this->initializePage($title, $content);
}
public function getPureContent()
{
return $this->content;
}
public function getContent()
{
if (is_null($this->generated)) {

Bestand weergeven

@ -81,7 +81,7 @@ class ContentPage extends \Todaymade\Daux\Format\Base\ContentPage
'modified_time' => filemtime($this->file->getPath()),
'markdown' => $this->content,
'request' => $params['request'],
'content' => $this->convertPage($this->content),
'content' => $this->getPureContent(),
'breadcrumbs' => $params['html']['breadcrumbs'],
'prev' => $this->file->getPrevious(),
'next' => $this->file->getNext(),

Bestand weergeven

@ -33,7 +33,7 @@ class ErrorPage extends SimplePage
$params = $this->params;
$page = [
'title' => $this->title,
'content' => $this->content,
'content' => $this->getPureContent(),
'language' => '',
];