/** * Returns data to render template * * @param array $options * * @throws WidgetEntityNotFoundException * @throws WidgetParameterException * * @return array */ public function getData($options) { if (!empty($options) && array_key_exists('account', $options) && !empty($options['account'])) { $id = $options['account']; $account = $this->accountRepository->find($id); if (!$account) { throw new WidgetEntityNotFoundException('Entity \'Account\' with id ' . $id . ' not found!', $this->widgetName, $id); } return $this->parseAccount($account); } return null; }
/** * {@inheritdoc} * * @throws WidgetEntityNotFoundException * @throws WidgetParameterException */ public function getData($options) { $data = []; if (!empty($options)) { $ids = $this->getValue($this->keys['ids'], $options, null); $limit = $this->getValue($this->keys['limit'], $options, null); $headline = $this->getValue($this->keys['headline'], $options, null); // set headline if ($headline) { $data['headline'] = $headline; } if ($ids) { // Parse accounts $accountIds = explode(',', $ids); foreach ($accountIds as $index => $id) { // check if limit is exceeded if ($limit && $index >= $limit) { $data['further'] = count($accountIds) - $limit; break; } // fetch and parse account data $account = $this->accountRepository->find($id); if (!$account) { throw new WidgetEntityNotFoundException('Entity \'Account\' with id ' . $id . ' not found!', $this->widgetName, $id); } $data['accounts'][] = $this->parseAccount($account); } } // set emptylabel if (isset($this->keys['emptyLabel'])) { $data['emptyLabel'] = $this->keys['emptyLabel']; } return $data; } }
/** * 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; }