예제 #1
0
 public function getActiveArticlesByAuthor(User $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;
 }
 /**
  * {@inheritDoc}
  */
 public function getId()
 {
     if ($this->__isInitialized__ === false) {
         return (int) parent::getId();
     }
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'getId', array());
     return parent::getId();
 }