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.

NewsStore.php 1.2KB

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