選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

47 行
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. }