| Conditions | 4 |
| Paths | 4 |
| Total Lines | 28 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 31 | public function validate($request, Constraint $constraint): void |
||
| 32 | { |
||
| 33 | $cart = $this->cartRepository->findOneBy([ |
||
| 34 | 'tokenValue' => $request->cartId, |
||
| 35 | 'state' => OrderInterface::STATE_CART, |
||
| 36 | ]); |
||
| 37 | |||
| 38 | if (null === $cart) { |
||
| 39 | return; |
||
| 40 | } |
||
| 41 | |||
| 42 | if (!isset($request->cartItem)) { |
||
| 43 | $this->context->addViolation($constraint->message); |
||
| 44 | |||
| 45 | return; |
||
| 46 | } |
||
| 47 | |||
| 48 | $orderItem = $cart->getItems()->matching( |
||
| 49 | Criteria::create() |
||
| 50 | ->where( |
||
| 51 | Criteria::expr()->eq('id', $request->cartItem->item_id) |
||
| 52 | ) |
||
| 53 | )->first(); |
||
| 54 | |||
| 55 | if (false === $orderItem) { |
||
| 56 | $this->context->addViolation($constraint->message); |
||
| 57 | } |
||
| 58 | } |
||
| 59 | } |
||
| 60 |