Just in case, someone else attacks this question (like me):
The @Florian stretch request mentioned has turned it into a doctrine. Although the documentation still does not contain any information on the CUSTOM identifier generation strategy. Only the part I found where the CUSTOM parameter for IdGenerator is specified is in the GeneratedValue description. If I missed this, please correct me in the comments.
It’s hard to implement it. Just create a class extending Doctrine\ORM\Id\AbstractIdGenerator\AbstractIdGenerator :
namespace My\Namespace; use Doctrine\ORM\Id\AbstractIdGenerator; class MyIdGenerator extends AbstractIdGenerator { public function generate(\Doctrine\ORM\EntityManager $em, $entity) {
Then add it to the id description in the doctrine entity configuration ( YAML example):
My\Bundle\Entity\MyEntity: type: entity id: id: type: bigint unique: true generator: strategy: CUSTOM customIdGenerator: class: 'My\Namespace\MyIdGenerator' fields: otherField: ....
If you use Annotations instead of YAML, the configuration of the object should look like this (unchecked):
/** * @Id * @Column(type="integer") * @GeneratedValue(strategy="CUSTOM") * @CustomIdGenerator(class="My\Namespace\MyIdGenerator") */ public $id;
And all this;)
enricog Feb 17 '15 at 12:00 2015-02-17 12:00
source share