public function countByAuthor(User $user)
{
$qb = $this->getEntityManager()->createQueryBuilder();
$qb->select('count(a)')->from('Newscoop\\Entity\\Article', 'a')->from('Newscoop\\Entity\\ArticleAuthor', 'aa')->from('Newscoop\\Entity\\User', 'u')->where('a.number = aa.articleNumber')->andWhere('a.language = aa.languageId')->andWhere('aa.author = u.author')->andwhere('u.id = :user')->andWhere($qb->expr()->in('a.type', array('news', 'blog')))->andWhere('a.workflowStatus = :status')->setParameters(array('user' => $user->getId(), 'status' => Article::STATUS_PUBLISHED));
$count = $qb->getQuery()->getSingleScalarResult();
return (int) $count;
}