Beispiel #1
0
 /**
  * Sets the customer account of an order.
  *
  * @param array $data
  * @param Order $order
  * @param bool $patch
  *
  * @throws MissingOrderAttributeException
  * @throws OrderDependencyNotFoundException
  *
  * @return null|object
  */
 private function setCustomerAccount(array $data, Order $order, $patch = false)
 {
     $accountData = $this->getProperty($data, 'customerAccount');
     if ($accountData) {
         if (!array_key_exists('id', $accountData)) {
             throw new MissingOrderAttributeException('account.id');
         }
         $account = $this->accountRepository->find($accountData['id']);
         if (!$account) {
             throw new OrderDependencyNotFoundException('Account', $accountData['id']);
         }
         $order->setCustomerAccount($account);
         return $account;
     } elseif (!$patch) {
         $order->setCustomerAccount(null);
     }
     return null;
 }