public function findOneBySlug($slug)
    {
        $query = $this->createQueryBuilder('c')
            ->where('c.slug = :slug')
            ->setParameter('slug', $slug)
            ->andWhere('c.publishAt < :now OR c.publishAt IS NULL')
            ->andWhere('c.active = :active')
            ->andWhere('c.layout = :layout')
            ->setParameter('now', new \DateTime())
            ->setParameter('active', true)
            ->setParameter('layout', false)
            ->setMaxResults(1)
            ->getQuery();

        return $query->useResultCache(true, self::CACHE_TTL)->getOneOrNullResult();
    }
public function findOneBySlug($slug)
    {
        $query = $this->createQueryBuilder('c')
            ->where('c.slug = :slug')
            ->setParameter('slug', $slug)
            ->andWhere('c.publishAt < :now OR c.publishAt IS NULL')
            ->andWhere('c.active = :active')
            ->andWhere('c.layout = :layout')
            ->setParameter('now', new \DateTime())
            ->setParameter('active', true)
            ->setParameter('layout', false)
            ->setMaxResults(1)
            ->getQuery();

        return $query->useResultCache(true, self::CACHE_TTL)->getOneOrNullResult();
    }
public function findOneBySlug ( $ slug ) { $ query = $ this -> createQueryBuilder ( 'c' ) -> where ( 'c.slug = :slug' ) -> setParameter ( 'slug' , $ slug ) -> andWhere ( 'c.publishAt < :now OR c.publishAt IS NULL' ) -> andWhere ( 'c.active = :active' ) -> andWhere ( 'c.layout = :layout' ) -> setParameter ( 'now' , new \ DateTime ( ) ) -> setParameter ( 'active' , true ) -> setParameter ( 'layout' , false ) -> setMaxResults ( 1 ) -> getQuery ( ) ; return $ query -> useResultCache ( true , self :: CACHE_TTL ) -> getOneOrNullResult ( ) ; }
Find one by slug.

@param string $slug

@return ContentInterface
Find one by slug .