Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Filters & hydrators #5099

Open
flip111 opened this Issue · 3 comments

2 participants

flip111 Marco Pivetta
flip111

I was trying to make a hydrator and using filters. I made a small code to use a hydrator with annotations. And i came to the following problems:

1.
->filter() does not have a generic interface. Sometimes only the propertyName is passed sometimes the \nameSpace\Class::Property
the FQCN is useful because then you can get the reflection information. But some combinations of hydrators and filters are not compatible.

2.
(This is more a problem about the hydrators)
There are only filters used for extracting and not hydrating. Of course you can filter the array yourself before you hydrate but then it's not good for re-use of code and seperation of concerns.

flip111

Here is an example where filter takes class::property
https://github.com/zendframework/zf2/blob/master/library/Zend/Stdlib/Hydrator/ClassMethods.php#L138

Here is an example where filter takes propertyName
https://github.com/zendframework/zf2/blob/master/library/Zend/Stdlib/Hydrator/Reflection.php#L34

There is no example of the filter taking the property value (but it could, because the interface/standard doesn't specify that).

I need a filter that can take the value as well as a ReflectionProperty (or get a class + property to build the reflection property from there)

Marco Pivetta
Collaborator

What about passing the hydrated/extraction object to the filter?

So basically modify filters to handle filter($propertyName, $object, $context)?

Just a wild guess on how this could be enhanced.

flip111

That would be perfect, it won't be compatible with the current interface though. Maybe it will work, but the interface doesn't specify this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.