/** * Returns data to render template. * * @param array $options * * @throws WidgetException * * @return array */ public function getData($options) { if (!empty($options) && array_key_exists('contact', $options) && !empty($options['contact'])) { $id = $options['contact']; $contact = $this->contactRepository->find($id); if (!$contact) { throw new WidgetEntityNotFoundException('Entity ' . $this->contactRepository->getClassName() . ' with id ' . $id . ' not found!', $this->widgetName, $id); } return $this->parseMainContact($contact); } return null; }
/** * Searches for contact in specified data and calls callback function. * * @param array $data * @param string $key * @param callable $addCallback * * @throws Exception\MissingOrderAttributeException * @throws Exception\OrderDependencyNotFoundException * * @return ContactInterface|null */ private function addContactRelation(array $data, $key, $addCallback) { $contact = null; if (array_key_exists($key, $data) && is_array($data[$key]) && array_key_exists('id', $data[$key])) { /** @var ContactInterface $contact */ $contactId = $data[$key]['id']; $contact = $this->contactRepository->find($contactId); if (!$contact) { throw new OrderDependencyNotFoundException($this->getContactEntityName(), $contactId); } $addCallback($contact); } return $contact; }