Bundle/BlogBundle/Repository/ArticleRepository.php
public function getAll($excludeUnpublished = false, Blog $blog = null)
    {
        $this->clearInstance();
        $this->qb = $this->getInstance();

        //If $excludeUnpublished === true, we exclude the non published results
        if ($excludeUnpublished) {
            $this->qb
                ->andWhere('article.status = :status')
                ->orWhere('article.status = :scheduled_status AND article.publishedAt <= :now')
                ->setParameter('status', PageStatus::PUBLISHED)
                ->setParameter('scheduled_status', PageStatus::SCHEDULED)
                ->setParameter('now', new \DateTime());
        }

        if (null != $blog) {
            $this->qb
                ->andWhere('article.blog = :blog')
                ->setParameter('blog', $blog->getId());
        }

        return $this;
    }
public function getAll($excludeUnpublished = false, Blog $blog = null)
    {
        $this->clearInstance();
        $this->qb = $this->getInstance();

        //If $excludeUnpublished === true, we exclude the non published results
        if ($excludeUnpublished) {
            $this->qb
                ->andWhere('article.status = :status')
                ->orWhere('article.status = :scheduled_status AND article.publishedAt <= :now')
                ->setParameter('status', PageStatus::PUBLISHED)
                ->setParameter('scheduled_status', PageStatus::SCHEDULED)
                ->setParameter('now', new \DateTime());
        }

        if (null != $blog) {
            $this->qb
                ->andWhere('article.blog = :blog')
                ->setParameter('blog', $blog->getId());
        }

        return $this;
    }
public function getAll ( $ excludeUnpublished = false , Blog $ blog = null ) { $ this -> clearInstance ( ) ; $ this -> qb = $ this -> getInstance ( ) ; //If $excludeUnpublished === true, we exclude the non published results if ( $ excludeUnpublished ) { $ this -> qb -> andWhere ( 'article.status = :status' ) -> orWhere ( 'article.status = :scheduled_status AND article.publishedAt <= :now' ) -> setParameter ( 'status' , PageStatus :: PUBLISHED ) -> setParameter ( 'scheduled_status' , PageStatus :: SCHEDULED ) -> setParameter ( 'now' , new \ DateTime ( ) ) ; } if ( null != $ blog ) { $ this -> qb -> andWhere ( 'article.blog = :blog' ) -> setParameter ( 'blog' , $ blog -> getId ( ) ) ; } return $ this ; }
Get all articles in the repository.

@param bool $excludeUnpublished Should we get only the published BasePages ?

@return ArticleRepository
Get all articles in the repository .