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.

RepositoryTrait.php 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. namespace Lc\CaracoleBundle\Repository;
  3. use Doctrine\Persistence\ManagerRegistry;
  4. use Lc\CaracoleBundle\Doctrine\Extension\FilterMerchantInterface;
  5. use Lc\CaracoleBundle\Doctrine\Extension\FilterSectionInterface;
  6. use Lc\CaracoleBundle\Resolver\MerchantResolver;
  7. use Lc\CaracoleBundle\Resolver\SectionResolver;
  8. // @TODO : à supprimer à terme, certainement
  9. trait RepositoryTrait
  10. {
  11. protected MerchantResolver $merchantResolver;
  12. protected SectionResolver $sectionResolver;
  13. public function __construct(
  14. ManagerRegistry $managerRegistry,
  15. SectionResolver $sectionResolver,
  16. MerchantResolver $merchantResolver
  17. ) {
  18. parent::__construct($managerRegistry);
  19. $this->merchantResolver = $merchantResolver;
  20. $this->sectionResolver = $sectionResolver;
  21. }
  22. /*protected function setCriteria(array $criteria) :array
  23. {
  24. $className = $this->getClassMetadata()->getName();
  25. $entity = new $className;
  26. if ($entity instanceof FilterMerchantInterface) {
  27. if (!isset($criteria['merchant'])) {
  28. $criteria['merchant'] = $this->merchantResolver->getCurrent();
  29. }
  30. if ($criteria['merchant'] === false) {
  31. unset($criteria['merchant']);
  32. }
  33. }
  34. if ($entity instanceof FilterSectionInterface) {
  35. if (!isset($criteria['section'])) {
  36. $criteria['section'] = $this->sectionResolver->getCurrent();
  37. }
  38. if ($criteria['section'] === false) {
  39. unset($criteria['section']);
  40. }
  41. }
  42. return $criteria;
  43. }*/
  44. }