1
0
Fork 0
mirror of synced 2025-04-20 01:21:01 +00:00

check if user exists in the order before building corporate customer

This commit is contained in:
Pavel 2020-07-30 15:22:35 +03:00
parent 4ba68803f0
commit ba720d27f4

View file

@ -212,7 +212,13 @@ class CorporateCustomerBuilder implements BuilderInterface
public function setOrder(Order $order): CorporateCustomerBuilder
{
$this->order = $order;
$this->user = UserRepository::getById($order->getUserId());
$userId = $order->getUserId();
if (null === $userId || !is_int($userId)) {
throw new BuilderException('Either user in order is not set or user id is not valid.');
}
$this->user = UserRepository::getById($userId);
return $this;
}