<?php
namespace Plugin\Topics42\Repository;
use Eccube\Repository\AbstractRepository;
use Doctrine\Persistence\ManagerRegistry as RegistryInterface;
use Eccube\Entity\News;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Criteria;
/**
* CampaignRepository.
*
* This class was generated by the Doctrine ORM. Add your own custom
* repository methods below.
*/
class TopicsRepository extends AbstractRepository
{
/**
* CouponRepository constructor.
*
* @param RegistryInterface $registry
*/
public function __construct(RegistryInterface $registry)
{
parent::__construct($registry, News::class);
}
public function getDispNewsAll(){
// second level cacheを効かせるためfindByで取得
$Results = $this->findBy(['visible' => true], ['publish_date' => 'DESC', 'id' => 'DESC']);
// 公開日時前のNewsをフィルター
$criteria = Criteria::create();
$criteria->where(Criteria::expr()->lte('publish_date', new \DateTime()));
$News = new ArrayCollection($Results);
return $News->matching($criteria);
}
}