Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Extending the user entity of ZfcUserDoctrineORM in ZF2

I'm quite new to ZF2. I have a bunch of doctrine entities from my project in ZF1, one being a User entity.

I'm trying to extend \ZfcUserDoctrineORM\Entity\User so that I can inclue my old relationships - but with no great success.

If I try and run the schema generator ./doctrine-module orm:schema-tool:create I get an error saying the table name user already exists.

So far I've tried extending the class and setting my class as the UserEntityClass

return array(
    'zfcuser' => array(
        'UserEntityClass' => '\Application\Entity\User',
    ),
);

There doen't seem to be any documentation for the module as yet.

like image 587
briangallagher Avatar asked Sep 22 '12 09:09

briangallagher


2 Answers

So the problem was that the default ZfcUserDoctrineORM entities were still in play. To solve this you can set EnableDefaultEntities to false like so :

return array(
    'zfcuser' => array(
        'UserEntityClass' => '\Acme\Entity\User',
        'EnableDefaultEntities' => false
    ),
);
like image 81
briangallagher Avatar answered Sep 20 '22 20:09

briangallagher


I'm going from memory here, as I played around with ZfcUser[DoctrineORM] some time back.

You don't want to extend anything. Instead, just write your own User entity and make it implement ZfcUser\Entity\UserInterface.

Then make sure you set your configuration correctly (to use your own implementation of UserInterface, instead of the default), and you should be good to go.

like image 27
timdev Avatar answered Sep 18 '22 20:09

timdev