Final Class Yiisoft\Hydrator\Validator\ValidatingHydrator
| Inheritance | Yiisoft\ |
|---|---|
| Implements | Yiisoft\ |
ValidatingHydrator is a decorator for {@see HydratorInterface}:
- it allows to validate raw data of properties marked with {@see \
Yiisoft\ Hydrator\ Validator\ Validate} PHP attribute before passing it to the decorated hydrator; - it allows to validate object after creating or populating it.
Public Methods
Method Details
| public mixed __construct ( \ | ||
| $hydrator | \ |
Hydrator to decorate. |
| $validator | \ |
Validator to use. |
| $validateResolver | Yiisoft\ |
Resolver for {@see \ |
public function __construct(
private HydratorInterface $hydrator,
private ValidatorInterface $validator,
private ValidateResolver $validateResolver,
) {}
| public object create ( string $class, array|\ | ||
| $class | string | |
| $data | array|\ |
|
public function create(string $class, array|DataInterface $data = []): object
{
$result = $this->beforeAction();
$object = $this->hydrator->create($class, $data);
$this->afterAction($object, $result);
return $object;
}
| public void hydrate ( object $object, array|\ | ||
| $object | object | |
| $data | array|\ |
|
public function hydrate(object $object, array|DataInterface $data = []): void
{
$result = $this->beforeAction();
$this->hydrator->hydrate($object, $data);
$this->afterAction($object, $result);
}
User Contributed Notes
Leave a comment
Join the conversation to share a note.