1

当我将 FosUserBundle 与 Sylius 和 PUGXMultiUserBundle 一起使用以创建一种以上类型的用户(角色)时,我在注册用户时遇到问题:

用户.php:

namespace Sylius\Bundle\CoreBundle\Model;

use DateTime;
use Doctrine\Common\Collections\ArrayCollection;
use FOS\UserBundle\Model\User as BaseUser;
use Sylius\Bundle\AddressingBundle\Model\AddressInterface;

/**
 * @ORM\Entity(repositoryClass="App\myBundle\Entity\UserRepository")
 * @ORM\Table(name="sylius_user")
 * @ORM\InheritanceType("JOINED")
 * @ORM\DiscriminatorColumn(name="user_type", type="string")
 * @ORM\DiscriminatorMap({"student" = "StudentUser", "partner" = "PartnerUser"})

 abstract class User extends BaseUser implements UserInterface
 {
protected $firstName;
protected $lastName;
protected $createdAt;
protected $updatedAt;
protected $currency;
protected $orders;
protected $billingAddress;
protected $shippingAddress;
protected $addresses;

.....

学生用户.php:

use Doctrine\ORM\Mapping as ORM;
use PUGX\MultiUserBundle\Validator\Constraints\UniqueEntity;

use Sylius\Bundle\CoreBundle\Model\User;

/**
 * @ORM\Entity(repositoryClass="App\MyBundle\Entity\UserRepository")
 * @ORM\Table(name="sylius_user_staff")
 * @UniqueEntity(fields = "username", targetClass = "Sylius\Bundle\CoreBundle\Model\User", message="fos_user.username.already_used")
 * @UniqueEntity(fields = "email", targetClass = "Sylius\Bundle\CoreBundle\Model\User", message="fos_user.email.already_used")
 */
class StudentUser extends User
{
/**
 * @ORM\Id
 * @ORM\Column(type="integer")
 * @ORM\GeneratedValue(strategy="AUTO")
 */
protected $id;

/**
 * Get id
 *
 * @return integer 
 */
public function getId()
{
    return $this->id;
}
} 

所以当我要注册一个新学生时,我收到了这个错误:

SQLSTATE[42S22]: Column not found: 1054 Unknown column 't0.username_canonical' in 'where clause' 

这直接意味着他们在 User.php 类(Sylius\Bundle\CoreBundle\Model)中找不到 username_canonical 并且他拒绝从 FosUserBundle 的 User.php 类扩展它?有人有解决方案吗?

4

0 回答 0