deblan.tv/src/Deblan/Bundle/BlogBundle/Model/Post.php

54 lines
1.3 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();
}
public function getElasticContent()
{
return strip_tags($this->getContent());
}
}