I am starting with Symfony2 and Doctrine. Now that I have my first actions including database interaction through doctrine running I want to create a manyToOne association for two entities. I started in the beginning with defining the model with Doctrine config files in YAML.
E.g. (Already including the manyToOne association)
Carsetup\MainBundle\Entity\VehicleWheelCombination:
type: entity
table: vehicle_wheel_combination
indexes:
vehicle_wheel_combinations_rim:
columns:
- rim_id
vehicle_wheel_combinations_spacer:
columns:
- spacer_id
vehicle_wheel_combinations_tyre:
columns:
- tyre_id
vehicle_wheel_combinations_vehicles:
columns:
- vehicle_id
id:
id:
type: integer
nullable: false
unsigned: false
comment: ''
id: true
generator:
strategy: IDENTITY
fields:
streetLegal:
type: boolean
nullable: false
comment: ''
column: street_legal
manyToOne:
rim:
targetEntity: Rim
cascade: { }
mappedBy: null
inversedBy: null
joinColumns:
rim_id:
referencedColumnName: id
orphanRemoval: false
spacer:
targetEntity: Spacer
cascade: { }
mappedBy: null
inversedBy: null
joinColumns:
spacer_id:
referencedColumnName: id
orphanRemoval: false
tyre:
targetEntity: Tyre
cascade: { }
mappedBy: null
inversedBy: null
joinColumns:
tyre_id:
referencedColumnName: id
orphanRemoval: false
vehicle:
targetEntity: Vehicle
cascade: { }
mappedBy: null
inversedBy: null
joinColumns:
vehicle_id:
referencedColumnName: id
orphanRemoval: false
manyToOne:
rating:
targetEntity: Rating
cascade: { }
mappedBy: null
inversedBy: null
orphanRemoval: false
lifecycleCallbacks: { }
Based on these configs I generated the entities. When I now re-generate the the entity, no getter or setter for the association is being created. Command used:
php app/console doctrine:generate:entities Carsetup/MainBundle/Entity/VehicleWheelCombination
Yes, I can create the association directly in the entity, but what I am failing to understand is: What is the actual reason for the config files then? Why dont I just create entities in the first place? Or am I doing simply something wrong?
Thanks!