Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Allowed HydratingResultSet to accept a PrototypeFactoryInterface #19

Conversation

waddedMeat
Copy link

This change allows an instance of a PrototypeFactoryInterface to be used
instead of an object prototype. The factory will be passed the result
data and must return an object to be hydrated.

This would resolve Issue #18

This change allows an instance of a PrototypeFactoryInterface to be used
instead of an object prototype.  The factory will be passed the result
data and must return an object to be hydrated.
$factory->expects($this->once())
->method('createPrototype')
->with($dataSource[0])
->will($this->returnValue(new \ArrayObject));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Import ArrayObject, instead of using global qualifier. Same with ArrayIterator above.

@weierophinney
Copy link
Member

I'm not convinced we need this; this sounds like a very application-specific use case, which would warrant a custom hydrator implementation.

As an example, you could overload DelegatingHydrator::hydrate() to introspect the $data argument to determine the object type to pass to its getHydrator() method. This seems like a cleaner solution than altering zend-db, as it separates the logic of object creation from the zend-db component — which was the original point of having the HydratingResultSet.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants