In this tip I want to show you how to correctly setup associations in ORM Designer Doctrine2 project. Because Doctrine2 supports one-way or bidirectional associations, there is a need to tell ORM Designer how to export it. This is proceeded by Association alias. When you create association between two entities, you have to enter how you would like to access from one entity to another. Currently there are three ways how to do it:
Setup alias in association wizard
When you are creating a new association by using association wizard, you have to enter alias for direction you want to use. Below the alias edit boxes is a “Direction” item which shows you a type of created association.
Setup alias in association editor
Another option is to setup association alias in association editor (executed by “Edit object” menu item or simply double click on the association). In this window there are simmilar edit boxes as in the association wizard. Depending on values you entered into edit boxes the association is exported to your Doctrine2 schema files.
Enter alias using Property Editor
The third option how to setup association alias is in Property editor. Simply select the association you want to setup and in Property editor enter Owning alias or Property alias value.
I hope that this tip will help you to understand a way how ORM Designer proceeds associations export. Because Doctrine2 supports multi-direction associations, it is required this “Alias-enter” step. Please, leave us your comment about this feature if you have any opinion.