| Conditions | 4 |
| Paths | 4 |
| Total Lines | 22 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 23 | public function assign(OrderInterface $order): void |
||
| 24 | { |
||
| 25 | $session = new Session(); |
||
| 26 | |||
| 27 | if (!$session->has(AffiliateReferralInterface::TOKEN_PARAM_NAME)) { |
||
| 28 | return; |
||
| 29 | } |
||
| 30 | |||
| 31 | /** @var AffiliateReferralInterface|null $affiliateReferral */ |
||
| 32 | $affiliateReferral = $this->affiliateReferralRepository->findOneBy([ |
||
| 33 | 'tokenValue' => $session->get(AffiliateReferralInterface::TOKEN_PARAM_NAME) |
||
| 34 | ]); |
||
| 35 | |||
| 36 | if (null === $affiliateReferral) { |
||
| 37 | return; |
||
| 38 | } |
||
| 39 | |||
| 40 | if ($order instanceof AffiliateReferralAwareInterface) { |
||
| 41 | $order->setAffiliateReferral($affiliateReferral); |
||
| 42 | } |
||
| 43 | |||
| 44 | $session->remove(AffiliateReferralInterface::TOKEN_PARAM_NAME); |
||
| 45 | } |
||
| 47 |