34 lines
992B

  1. <?php
  2. namespace Lc\ShopBundle\Repository;
  3. use App\Entity\News;
  4. use Lc\ShopBundle\Context\DefaultRepositoryInterface;
  5. use Lc\ShopBundle\Context\NewsInterface;
  6. /**
  7. * @method News|null find($id, $lockMode = null, $lockVersion = null)
  8. * @method News|null findOneBy(array $criteria, array $orderBy = null)
  9. * @method News[] findAll()
  10. * @method News[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
  11. */
  12. class NewsRepository extends BaseRepository implements DefaultRepositoryInterface
  13. {
  14. public function getInterfaceClass()
  15. {
  16. return NewsInterface::class;
  17. }
  18. public function findLatests($maxResults = 0)
  19. {
  20. $result = $this->findByMerchantQuery()
  21. ->orderBy('e.date', 'DESC') ;
  22. if($maxResults) {
  23. $result->setMaxResults($maxResults) ;
  24. }
  25. return $result->getQuery()->getResult() ;
  26. }
  27. }