/** * @param array|Traversable|stdClass $data * @return Court * @throws ModelNotFoundException * @throws UnauthorizedException * @throws ServiceException */ public function populate($data) { /** @var $inputFilter */ $inputFilter = $this->getPopulateInputFilter($data); if (!$inputFilter->isValid()) { throw new InvalidInputException( 'Unable to update court because of invalid input', 0, null, $inputFilter->getMessages() ); } /** @var Court $court */ $court = $this->baseHydrator->hydrate($inputFilter->getValues(), $this->courtRepository->find($inputFilter->getValue('id'))); if (!$this->resourcePermissionService->isAllowedToCourt($court, 'update')) { throw new UnauthorizedException( sprintf('Not authorized to update court with identifier %d', $court->getId()) ); } return $court; }