check if user exists in the order before building corporate customer
This commit is contained in:
parent
4ba68803f0
commit
ba720d27f4
1 changed files with 7 additions and 1 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue