Skip to content

Add support for alternate Hydrator generation methods #953

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from

Conversation

kperry42
Copy link
Contributor

@kperry42 kperry42 commented Oct 3, 2014

This implements two new auto-gen modes for hydrators: AUTOGENERATE_FILE_NOT_EXISTS and AUTOGENERATE_EVAL, per our discussion labelled issue #889.

When I dug into the code, I discovered that \Doctrine\Common\Proxy\AbstractProxyFactory already implemented exactly the same algorithms that I wanted for Hydrators, even including eval() mode. So I've closely patterned my HydratoryFactory mods after the code in AbstractProxyGenerator. I also put the constant definitions for the different auto-gen modes into the Configuration class, for easy reference.

AUTOGENERATE_FILE_NOT_EXISTS and AUTOGENERATE_EVAL.
const AUTOGENERATE_FILE_NOT_EXISTS = 2;

/**
* Generate the proxy classes using eval().
Copy link
Member

Choose a reason for hiding this comment

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

Should be "proxy/hydrator" instead of "proxy"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops, yes, I missed that one.

@malarzm
Copy link
Member

malarzm commented Oct 3, 2014

👍 I'll need this in upcoming week :)

@kperry42
Copy link
Contributor Author

kperry42 commented Oct 3, 2014

Thanks. Yeah, I'm running in EVAL mode now - it's great.

On 10/03/2014 11:43 AM, Maciej Malarz wrote:

👍 I'll need this in upcoming week :)


Reply to this email directly or view it on GitHub
#953 (comment).

Kevin Perry
OIT Academic Technology Services
Princeton University
perry@princeton.edu

@gruberro
Copy link

+1

@@ -137,10 +138,27 @@ public function getHydratorFor($className)

if ( ! class_exists($fqn, false)) {
$fileName = $this->hydratorDir . DIRECTORY_SEPARATOR . $hydratorClassName . '.php';
if ($this->autoGenerate) {
$this->generateHydratorClass($class, $hydratorClassName, $fileName);
switch ($this->autoGenerate) {
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point. Done.

malarzm added a commit that referenced this pull request Mar 30, 2015
@malarzm
Copy link
Member

malarzm commented Mar 30, 2015

Merged in f04de2e - thanks @kperry42!

@jmikola
Copy link
Member

jmikola commented Mar 31, 2015

Late to the party here, but if we end up adopting Common's proxy generator down the line, will this port over nicely? I don't recall if we had an outstanding TODO ticket for that, but I seem to recall talking about it with @Ocramius last year.

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

Successfully merging this pull request may close these issues.

5 participants