Sylius+FOS+PUGX Multi User: Overriding User Model

筅森魡賤 提交于 2019-12-08 09:41:44

问题


Sylius with FOS and PUGX MultiUser Bundle that allows registering of 3 different users via 3 different forms, with 3 different roles, etc. Since Sylius User is defined as:

->Sylius\Component\Core\Model\User.php

namespace Sylius\Component\Core\Model;

use FOS\UserBundle\Model\User as BaseUser;
use Sylius\Component\Addressing\Model\AddressInterface;

class User extends BaseUser implements UserInterface{
...
}

Since userOne and userTwo are supposed to extend an abstract class, as per PUGX multiuser Bundle docs, we have:

->Acme\UserBundle\Entity\User.php

namespace Acme\UserBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use Sylius\Component\Core\Model\User as BaseUser;

/**
 * @ORM\Entity
 * @ORM\Table(name="sylius_user_pugx")
 * @ORM\InheritanceType("JOINED")
 * @ORM\DiscriminatorColumn(name="type", type="string")
 * @ORM\DiscriminatorMap({"userone" = "Acme\UserBundle\Entity\userOne", "userTwo" = "Acme\UserBundle\Entity\userTwo", "userThree" = "Acme\UserBundle\Entity\Admin"})
 *
 */
abstract class User extends BaseUser {...}

So now we only need, our REAL final classes:

->Acme\UserBundle\Entity\userOne.php

namespace Acme\UserBundle\Entity;

use Mod\UserBundle\Entity\User as User;

/**
 * @ORM\Entity
 * @ORM\Table(name="userOne")
 * @UniqueEntity(fields = "username", targetClass = "Acme\UserBundle\Entity\User", message="fos_user.username.already_used")
 * @UniqueEntity(fields = "email", targetClass = "Acme\UserBundle\Entity\User", message="fos_user.email.already_used")
 */
class userOne extends User {..}

So we are extending this way: userOne extends 'Abstract User' extends 'Sylius User' extends 'FOS User'.

But I can't update my schema: The table with name 'bbdd.sylius_user_address' already exists

What am I doing wrong? Isn't it the logical way the user classes should extend each other?

来源:https://stackoverflow.com/questions/26538916/syliusfospugx-multi-user-overriding-user-model

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!