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 anni fa
3 anni fa
3 anni fa
3 anni fa
3 anni fa
3 anni fa
3 anni fa
3 anni fa
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. $query->orderBy('id');
  16. return $query;
  17. }
  18. public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
  19. {
  20. return $query;
  21. }
  22. public function relationsDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
  23. {
  24. return $query;
  25. }
  26. // findLatests
  27. public function getLatests(int $maxResults = 0, $query = null): array
  28. {
  29. $query = $this->createDefaultQuery($query);
  30. $query
  31. ->filterIsOnline()
  32. ->orderBy('.date', 'DESC');
  33. if ($maxResults) {
  34. $query->limit($maxResults);
  35. }
  36. return $query->find();
  37. }
  38. }