mirror of
https://github.com/silverstripe/silverstripe-blog
synced 2024-10-22 11:05:58 +02:00
FIX #394 add getDate to proxy publish date in rss template
This commit is contained in:
parent
c1ae82b74b
commit
299944fd1f
@ -686,6 +686,17 @@ class BlogPost extends Page
|
|||||||
return $labels;
|
return $labels;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Proxy method for displaying the publish date in rss feeds.
|
||||||
|
* @see https://github.com/silverstripe/silverstripe-blog/issues/394
|
||||||
|
*
|
||||||
|
* @return string|null
|
||||||
|
*/
|
||||||
|
public function getDate()
|
||||||
|
{
|
||||||
|
return !empty($this->PublishDate) ? $this->PublishDate : null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
|
@ -94,4 +94,17 @@ class BlogPostTest extends SapphireTest
|
|||||||
$visitor = $this->objFromFixture('Member', 'Visitor');
|
$visitor = $this->objFromFixture('Member', 'Visitor');
|
||||||
$this->assertFalse($blogPost->canView($visitor));
|
$this->assertFalse($blogPost->canView($visitor));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The purpose of getDate() is to act as a proxy for PublishDate in the default RSS
|
||||||
|
* template, rather than copying the entire template.
|
||||||
|
*/
|
||||||
|
public function testGetDate()
|
||||||
|
{
|
||||||
|
$blogPost = $this->objFromFixture('BlogPost', 'NullPublishDate');
|
||||||
|
$this->assertNull($blogPost->getDate());
|
||||||
|
|
||||||
|
$blogPost = $this->objFromFixture('BlogPost', 'PostA');
|
||||||
|
$this->assertEquals('2012-01-09 15:00:00', $blogPost->getDate());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user