<?php

namespace Lc\ShopBundle\Repository;

use App\Entity\News;
use Lc\ShopBundle\Context\DefaultRepositoryInterface;
use Lc\ShopBundle\Context\NewsInterface;

/**
 * @method News|null find($id, $lockMode = null, $lockVersion = null)
 * @method News|null findOneBy(array $criteria, array $orderBy = null)
 * @method News[]    findAll()
 * @method News[]    findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
 */
class NewsRepository extends BaseRepository implements DefaultRepositoryInterface
{
        public function getInterfaceClass()
        {
                return NewsInterface::class;
        }

        public function findLatests($maxResults = 0)
        {
                $result = $this->findByMerchantQuery()
                        ->orderBy('e.date', 'DESC') ;

                if($maxResults) {
                        $result->setMaxResults($maxResults) ;
                }

                return $result->getQuery()->getResult() ;
        }
}