|
- <?php
-
- namespace Lc\SovBundle\Repository\Site;
-
- use Lc\SovBundle\Repository\AbstractStore;
-
- class NewsStore extends AbstractStore implements NewsStoreInterface
- {
- protected NewsRepositoryQueryInterface $query;
-
- public function __construct(NewsRepositoryQueryInterface $query)
- {
- $this->query = $query;
- }
-
- //findLatests
- public function getLatests(int $maxResults = 0, $query = null): array
- {
- if (is_null($query)) {
- $query = $this->query->create();
- }
- $query
- ->filterIsOnline()
- ->orderBy('.date', 'DESC');
-
- if ($maxResults) {
- $query
- ->limit($maxResults);
- }
-
- return $query->find();
- }
-
- public function findLatests($maxResults = 0)
- {
- $result = $this->findByMerchantQuery()
- ->orderBy('e.date', 'DESC');
-
- $result->andWhere('e.status = 1');
-
- if ($maxResults) {
- $result->setMaxResults($maxResults);
- }
-
- return $result->getQuery()->getResult();
- }
- }
|