コード例 #1
0
    /**
     * {@inheritdoc}
     */
    public function hydrate($value)
    {
        if (is_object($value)) {
            return $value;
        }

        return $this->baseHydrator->hydrate($value, new $this->modelName());
    }
コード例 #2
0
ファイル: FacilityHydrator.php プロジェクト: jbarentsen/drb
    /**
     * 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);
    }
コード例 #3
0
ファイル: CourtService.php プロジェクト: jbarentsen/drb
    /**
     * @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;
    }
コード例 #4
0
ファイル: IdentifierHydrator.php プロジェクト: jbarentsen/drb
    /**
     * {@inheritdoc}
     */
    public function __construct(ObjectManager $objectManager, $byValue = true)
    {
        parent::__construct($objectManager, $byValue);

        $this->addFilter('main', new IdentifierHydratorFilter());
    }
コード例 #5
0
ファイル: AddressHydrator.php プロジェクト: jbarentsen/drb
 /**
  * @param ObjectManager $objectManager
  * @param bool $byValue
  */
 public function __construct(ObjectManager $objectManager, $byValue = true)
 {
     parent::__construct($objectManager, $byValue);
 }