I have two classes
class Topic
{
protected $id;
//....
}
and
class Post
{
protected $topic_id;
//...
}
and I would like add method getPostCount() in Topic class. In other frameworks I used to use something like that:
public function getPostCount()
{
$count = Post::find()
->where(['topic_id' => $this->id])
->count();
return $count;
}
but in symfony2 I don't know how to make it.