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.

47 satır
1.3KB

  1. <?php
  2. namespace Lc\CaracoleBundle\Solver\Reduction;
  3. use Lc\CaracoleBundle\Model\Reduction\ReductionCartInterface;
  4. use Lc\SovBundle\Model\User\UserInterface;
  5. class ReductionCartSolver
  6. {
  7. // isReductionCartMatchWithUser
  8. public function matchWithUser(ReductionCartInterface $reductionCart, UserInterface $user)
  9. {
  10. $conditionUser = false;
  11. if ($user) {
  12. if ($reductionCart->getUsers()->isEmpty() || $reductionCart->getUsers()->contains($user)) {
  13. $conditionUser = true;
  14. }
  15. }
  16. return $conditionUser;
  17. }
  18. // isReductionCartMatchWithGroupUser
  19. public function matchWithGroupUser(ReductionCartInterface $reductionCart, UserInterface $user)
  20. {
  21. $conditionGroupUser = false;
  22. if ($user) {
  23. if ($user->getGroupUsers() && count($user->getGroupUsers()) > 0) {
  24. foreach ($user->getGroupUsers() as $groupUser) {
  25. if ($reductionCart->getGroupUsers()->isEmpty() || $reductionCart->getGroupUsers()->contains($groupUser)) {
  26. $conditionGroupUser = true;
  27. }
  28. }
  29. } else {
  30. if ($reductionCart->getGroupUsers()->isEmpty()) {
  31. $conditionGroupUser = true;
  32. }
  33. }
  34. }
  35. return $conditionGroupUser;
  36. }
  37. }