-
-
Notifications
You must be signed in to change notification settings - Fork 405
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
Doctrine embedded entity 'make:entity --regenerate' bugfix #164
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really cool! This, obviously, will fix the error. But, it will NOT actually generate the embeddable class, correct? The user will need to create this? (I know this exactly how we discussed it should work initially, I'm just checking).
If so, we need to do 1 more thing, and we have 2 options:
A) Warn the user that the embeddable has not been generated
B) Generate the embeddable
(B) MIGHT be easy, as embeddables are almost EXACTLY entity classes, just with a different annotation, no repository class and no id). But, it might not be easy :p.
$metadata = $this->doctrineHelper->getMetadata($classOrNamespace); | ||
} catch (MappingException $mappingException) { | ||
$metadata = $this->doctrineHelper->getMetadata($classOrNamespace, true); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea, that's a very practical idea.
src/Doctrine/EntityRegenerator.php
Outdated
|
||
$operations[$embeddedClasses[$fieldName]] = $this->createClassManipulator($embeddedClasses[$fieldName]); | ||
|
||
$manipulator->addEmbeddedEntity($fieldName, $mapping['class']); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- $manipulator->addEmbeddedEntity($fieldName, $mapping['class']);
+ $manipulator->addEmbeddedEntity($fieldName, $className);
} | ||
|
||
$this->addGetter($propertyName, $typeHint, false); | ||
$this->addSetter($propertyName, $typeHint, false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm curious. Is a setter "normal" or wanted for an embeddable? Or is it more common to mutate it (e.g. $myEntity->getEmbeddableField()->setSomeFieldOnEmbeddable('bar')
)? Or, both?
/** | ||
* @ORM\Embeddable() | ||
*/ | ||
class Recept |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Recipe
:) Fun example, btw
07d2162
to
0e36480
Compare
Thank you @sadikoff - awesome fix! |
Thanks @sadikoff 👍 |
Closes #160