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.

39 lines
954B

  1. <?php
  2. namespace Lc\CaracoleBundle\Repository\Section;
  3. use Lc\CaracoleBundle\Model\Section\SectionInterface;
  4. use Lc\CaracoleBundle\Repository\MerchantStoreTrait;
  5. use Lc\SovBundle\Repository\AbstractStore;
  6. use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
  7. class SectionStore extends AbstractStore
  8. {
  9. use MerchantStoreTrait;
  10. protected SectionRepositoryQuery $query;
  11. public function __construct(SectionRepositoryQuery $query)
  12. {
  13. $this->query = $query;
  14. }
  15. // getSection
  16. public function getOneByDevAlias(string $devAlias): ?SectionInterface
  17. {
  18. $query = $this->query->create();
  19. $query
  20. ->filterByMerchant($this->merchant)
  21. ->filterByDevAlias($devAlias);
  22. $section = $query->findOne();
  23. if (!$section) {
  24. throw new NotFoundHttpException('La section ' . $devAlias . ' est introuvable');
  25. }
  26. return $section;
  27. }
  28. }