您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

NewsStore.php 1.0KB

3 年前
3 年前
3 年前
3 年前
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. namespace Lc\SovBundle\Repository\Site;
  3. use Lc\SovBundle\Repository\AbstractStore;
  4. class NewsStore extends AbstractStore implements NewsStoreInterface
  5. {
  6. protected NewsRepositoryQueryInterface $query;
  7. public function __construct(NewsRepositoryQueryInterface $query)
  8. {
  9. $this->query = $query;
  10. }
  11. //findLatests
  12. public function getLatests(int $maxResults = 0, $query = null): array
  13. {
  14. if (is_null($query)) {
  15. $query = $this->query->create();
  16. }
  17. $query
  18. ->filterIsOnline()
  19. ->orderBy('.date', 'DESC');
  20. if ($maxResults) {
  21. $query
  22. ->limit($maxResults);
  23. }
  24. return $query->find();
  25. }
  26. public function findLatests($maxResults = 0)
  27. {
  28. $result = $this->findByMerchantQuery()
  29. ->orderBy('e.date', 'DESC');
  30. $result->andWhere('e.status = 1');
  31. if ($maxResults) {
  32. $result->setMaxResults($maxResults);
  33. }
  34. return $result->getQuery()->getResult();
  35. }
  36. }