Пример #1
0
 public function getActiveArticlesByAuthor(BlogUserInterface $author, $limit = null)
 {
     $articleClass = $this->_entityName;
     $query = "SELECT a FROM {$articleClass} a\n                  INNER JOIN a.author u\n                  WHERE a.status= :published AND a.publishedAt <= :cur\n                  AND a.author = :author_id\n                  ORDER BY a.publishedAt DESC";
     $query = $this->getEntityManager()->createQuery($query)->setParameter("published", Article::STATUS_PUBLISHED)->setParameter('cur', new \DateTime())->setParameter('author_id', $author->getId());
     if ($limit) {
         $query->setMaxResults($limit);
     }
     $articles = $query->useQueryCache(true)->setQueryCacheLifetime(60)->getResult();
     return $articles;
 }
Пример #2
0
 public function getDefaultBlogRole(BlogUserInterface $user)
 {
     $role = "ROLE_BLOG_CONTRIBUTOR";
     if ($user->hasRole('ROLE_BLOG_ADMIN')) {
         return 'ROLE_BLOG_ADMIN';
     } elseif ($user->hasRole('ROLE_BLOG_EDITOR')) {
         return 'ROLE_BLOG_EDITOR';
     } elseif ($user->hasRole('ROLE_BLOG_AUTHOR')) {
         return 'ROLE_BLOG_AUTHOR';
     }
     return $role;
 }