You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 satır
1.1KB

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