从FOSUserBundle继承User-Class时,doctrine将无法识别基本User类的继承属性。
只有我自己的类的属性才会用于创建/更新数据库模式。
这是config.yml:
config.yml:
doctrine:
orm:
auto_generate_proxy_classes: "%kernel.debug%"
naming_strategy: doctrine.orm.naming_strategy.underscore
auto_mapping: true
mappings:
FOSUserBundle: ~
AppBundle: ~
fos_user:
db_driver: orm
firewall_name: main
user_class: AppBundle\Entity\User
我的用户 - 实体:
<?php
namespace AppBundle\Entity;
use FOS\UserBundle\Model\User as BaseUser;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
/**
* @ORM\Entity()
* @ORM\Table(name="s_user")
*/
class User extends BaseUser
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/** @ORM\Column(name="facebook_id", type="string", length=255, nullable=true) */
protected $facebook_id;
/** @ORM\Column(name="facebook_access_token", type="string", length=255, nullable=true) */
protected $facebook_access_token;
/** @ORM\Column(name="google_id", type="string", length=255, nullable=true) */
protected $google_id;
/** @ORM\Column(name="google_access_token", type="string", length=255, nullable=true) */
protected $google_access_token;
public function __construct()
{
parent::__construct();
// your own logic
}
我在这里错了什么?
答案 0 :(得分:4)
尝试更改此行:
use FOS\UserBundle\Model\User as BaseUser;
要:
use FOS\UserBundle\Entity\User as BaseUser;
缺少的字段应添加到下一个schema:update --force