49 lines
1.2 KiB
PHP
49 lines
1.2 KiB
PHP
|
<?php
|
||
|
|
||
|
namespace Deblan\Bundle\BlogBundle\Model;
|
||
|
|
||
|
use Deblan\Bundle\BlogBundle\Model\om\BasePost;
|
||
|
|
||
|
class Post extends BasePost
|
||
|
{
|
||
|
public function getTagsCollection()
|
||
|
{
|
||
|
return array_map('trim', explode(',', $this->getTags()));
|
||
|
}
|
||
|
|
||
|
public function hasComments()
|
||
|
{
|
||
|
foreach ($this->getComments() as $comment) {
|
||
|
if ($comment->getActive()) {
|
||
|
return true;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
public function countActiveComments()
|
||
|
{
|
||
|
$criteria = new \Criteria();
|
||
|
$criteria->addAscendingOrderByColumn(CommentPeer::CREATED_AT);
|
||
|
$criteria->addAnd(CommentPeer::ACTIVE, true);
|
||
|
$criteria->addAnd(CommentPeer::POST_ID, $this->getId());
|
||
|
|
||
|
return CommentPeer::doCount($criteria);
|
||
|
}
|
||
|
|
||
|
public function getOrderedComments()
|
||
|
{
|
||
|
$criteria = new \Criteria();
|
||
|
$criteria->addAscendingOrderByColumn(CommentPeer::CREATED_AT);
|
||
|
$criteria->addAnd(CommentPeer::ACTIVE, true);
|
||
|
|
||
|
return $this->getComments($criteria);
|
||
|
}
|
||
|
|
||
|
public function getActiveFollowers()
|
||
|
{
|
||
|
return PostFollowerQuery::create()->filterByPost($this)->filterByActive(true)->find();
|
||
|
}
|
||
|
}
|