sonata-project/SonataEasyExtendsBundle — pull request #54 by stephen-leavitt-sonyatv-com (2014-09-03 17:01:12+00:00)
Title: Added support for addOverride method to allow for association and attribute overrides.

Issue #29 requested the addition of a method that would allow one to remove an association so that it could possibly be re-added. That issue was closed out of fear of possibly breaking code.

I propose an alternative, which I feel is the better way to handle this, and that's to add a method called addOverride to both DoctrineCollector and DoctrineORMMapper, which will allow one to override both attributes and associations as necessary in a Doctrine supported manner.

An example in the code that I'm using is as follows:

$collector = DoctrineCollector::getInstance();

$collector->addOverride($config['class']['user'], 'setAssociationOverride', array(
'fieldName' => 'groups',
'joinColumns' => array(
array(
'name' => 'user_id',
'referencedColumnName' => 'USER_ID',
'onDelete' => 'CASCADE'
)
)
));

This allows one to call setAssociationOverride and setAttributeOverride as necessary to achieve what ever overrides are needed in your application.