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

Aggregate hydrator #4448

Closed

Conversation

Ocramius
Copy link
Member

@Ocramius Ocramius commented May 8, 2013

As of #3829, this PR tries to implement a fairly flexible aggregate hydrator

@Ocramius
Copy link
Member Author

Ocramius commented May 8, 2013

Note: please ignore CS! I'm not handling CS until it is clear what path has to be taken.


public function add(HydratorInterface $hydrator, $priority = self::DEFAULT_PRIORITY)
{
$this->getEventManager()->attachAggregate(new HydratorListener($hydrator), $priority);
Copy link
Member Author

Choose a reason for hiding this comment

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

Feedback needed: this attaches both to the extract and the hydrate event with the same priority. Usually, extraction is symmetrical to hydration, should I therefore attach one with $priority and another with - $priority?

Copy link
Contributor

Choose a reason for hiding this comment

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

yes!

Copy link
Member Author

Choose a reason for hiding this comment

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

This remains a tricky one - @weierophinney any idea on how to make this flexible enough to avoid regretting any wrong choice now? :)

@juriansluiman
Copy link
Contributor

What are the benefits here of the EM? If you only need priorities, no short circuiting and reusing the same priority, I think you can use the Zend\Stdlib\PriorityQueue too? They are in the same component, so that saves another dependency.

@Ocramius
Copy link
Member Author

Ocramius commented May 8, 2013

@juriansluiman didn't think about the dependency: good point!

The basic use case for the EventManager here is applying decoration work on hydrated/extracted data.

A simple use case would be serialization of an object an adding HAL data to it later on.

Another use case may be removal of fields that are not allowed for displaying in frontend

* Attaches the provided hydrator to the list of hydrators to be used while hydrating/extracting data
*
* @param \Zend\Stdlib\Hydrator\HydratorInterface $hydrator
* @param int $priority
Copy link
Member Author

Choose a reason for hiding this comment

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

Will not make the HydratorListener symmetrical for now. I think that's a fairly advanced use case that should be handled by the user in very particular cases /cc @prolic

@ghost ghost assigned weierophinney May 9, 2013
weierophinney added a commit that referenced this pull request May 9, 2013
weierophinney added a commit that referenced this pull request May 9, 2013
weierophinney added a commit to zendframework/zend-stdlib that referenced this pull request May 15, 2015
…ture/aggregate-hydrator

[WIP] Aggregate hydrator
weierophinney added a commit to zendframework/zend-stdlib that referenced this pull request May 15, 2015
weierophinney added a commit to zendframework/zend-stdlib that referenced this pull request May 15, 2015
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.

5 participants