/** * {@inheritdoc} */ public function hydrate($value) { if (is_object($value)) { return $value; } return $this->baseHydrator->hydrate($value, new $this->modelName()); }
/** * Constructor * * @param BaseHydrator $baseHydrator * @param ObjectManager $objectManager * @param bool $byValue */ public function __construct( BaseHydrator $baseHydrator, ObjectManager $objectManager, $byValue = true ) { parent::__construct($objectManager, $byValue); $this->addFilter('main', new BaseHydratorFilter()); $baseStrategy = new BaseHydratorStrategy($baseHydrator, 'NcpFacility\Model\Facility\FacilityAddress'); $this->addStrategy('address', $baseStrategy); }
/** * @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; }
/** * {@inheritdoc} */ public function __construct(ObjectManager $objectManager, $byValue = true) { parent::__construct($objectManager, $byValue); $this->addFilter('main', new IdentifierHydratorFilter()); }
/** * @param ObjectManager $objectManager * @param bool $byValue */ public function __construct(ObjectManager $objectManager, $byValue = true) { parent::__construct($objectManager, $byValue); }