Skip to content

Conversation

@codedmonkey
Copy link
Contributor

Fixes faulty generation of entities with self-referencing associations #166. It looks like changes for the owning entity were overwritten by the changes for the inversed entity.

Copy link
Member

@weaverryan weaverryan left a comment

Choose a reason for hiding this comment

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

Thanks for taking on this old bug! Great work with the code & test - just a few minor comments :)

$newFieldName = $newField->getOwningProperty();
$otherManipulatorFilename = $this->getPathOfClass($newField->getInverseClass());
$otherManipulator = $this->createClassManipulator($otherManipulatorFilename, $io, $overwrite);
if ($newField->getInverseClass() !== $newField->getOwningClass()) {
Copy link
Member

Choose a reason for hiding this comment

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

Could we use some $newField->isSelfReferencingMethod() here?

private function addCollectionRelation(BaseCollectionRelation $relation)
{
$typeHint = $this->addUseStatementIfNecessary($relation->getTargetClassName());
$typeHint = !$relation->isSelfReferencing() ? $this->addUseStatementIfNecessary($relation->getTargetClassName()) : 'self';
Copy link
Member

Choose a reason for hiding this comment

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

Hmm, maybe reverse this - I think the ! is a bit confusing:

$typeHint = $relation->isSelfReferencing() ? 'self' : $this->addUseStatementIfNecessary($relation->getTargetClassName());

// do you want to generate an inverse relation? (default to yes)
'',
// field name on opposite side
'wards',
Copy link
Member

Choose a reason for hiding this comment

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

This word isn't commonly used in English. Using dependents might be better (A parent/guardian refers to their children as "dependents")

@weaverryan
Copy link
Member

Thank you @codedmonkey!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants