No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

57 líneas
1.7KB

  1. <?php
  2. namespace Lc\CaracoleBundle\Repository\User;
  3. use Lc\CaracoleBundle\Model\User\UserMerchantInterface;
  4. use Lc\CaracoleBundle\Repository\MerchantStoreTrait;
  5. use Lc\CaracoleBundle\Solver\User\UserMerchantSolver;
  6. use Lc\SovBundle\Model\User\UserInterface;
  7. use Lc\CaracoleBundle\Repository\AbstractStore;
  8. use Lc\SovBundle\Repository\RepositoryQueryInterface;
  9. class UserMerchantStore extends AbstractStore
  10. {
  11. use MerchantStoreTrait;
  12. protected UserMerchantRepositoryQuery $query;
  13. protected UserMerchantSolver $userMerchantSolver;
  14. public function __construct(UserMerchantRepositoryQuery $query, UserMerchantSolver $userMerchantSolver)
  15. {
  16. $this->query = $query;
  17. $this->userMerchantSolver = $userMerchantSolver;
  18. }
  19. public function orderByDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
  20. {
  21. $query->orderBy('id');
  22. return $query;
  23. }
  24. public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
  25. {
  26. $query->filterByMerchant($this->merchant);
  27. return $query;
  28. }
  29. public function relationsDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
  30. {
  31. return $query;
  32. }
  33. // getUserMerchant
  34. public function getOneByUser(UserInterface $user, $query = null): ?UserMerchantInterface
  35. {
  36. $query = $this->createDefaultQuery($query);
  37. $query->filterByUser($user);
  38. return $query->findOne();
  39. }
  40. public function isCreditActiveByUser(UserInterface $user, $query = null): bool
  41. {
  42. $userMerchant = $this->getOneByUser($user, $query);
  43. return $this->userMerchantSolver->isCreditActive($userMerchant);
  44. }
  45. }