我有这个用户实体从 BaseUser 扩展:
namespace PDOneBundle\Entity;
use FOS\UserBundle\Model\User as BaseUser;
use Doctrine\ORM\Mapping as ORM;
use PDOneBundle\Classes\Form\Validator\Constraints as GdcaAssert;
use Symfony\Component\Validator\Constraints as Assert;
use Gedmo\Mapping\Annotation as Gedmo;
use Gedmo\Timestampable\Traits\TimestampableEntity;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Security\Core\User\AdvancedUserInterface;
/**
* @ORM\Entity
* @ORM\HasLifecycleCallbacks
* @ORM\Table(name="fos_user")
* @ORM\Entity(repositoryClass="PDOneBundle\Entity\Repository\UserRepository")
* @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false)
*/
class User extends BaseUser
{
/*
* Hook timestampable behavior
* updates createdAt, updatedAt fields
*/
use TimestampableEntity;
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @var int
*
* @Assert\NotBlank()
*
* @ORM\ManyToOne(targetEntity="Company", inversedBy="users", cascade={"persist"})
* @ORM\JoinColumn(name="company_id", referencedColumnName="ID")
*/
protected $company;
/**
* @ORM\ManyToMany(targetEntity="Company", mappedBy="admins", cascade={"persist"})
*/
protected $companies;
/**
* @ORM\ManyToMany(targetEntity="Project", mappedBy="admins", cascade={"persist"})
*/
protected $projects;
// methods goes here
}
我也在使用 EasyAdminBundle,每当我尝试从 EasyAdmin 添加新用户时,都会出现以下错误:
属性“expiresAt”和方法之一“getExpiresAt()”、“expiresAt()”、“isExpiresAt()”、“hasExpiresAt()”、“__get()”都不存在并且在类“PDOneBundle\”中具有公共访问权限实体\用户”。
为什么?这些方法不应该是从 BaseUser 扩展而来的吗?为什么会出错?