属性 在 FOSUserBundle 从 BaseUser 扩展时未定义

Property not defined while extends from BaseUser at FOSUserBundle

我有这个用户实体从 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 添加新用户时,我都会收到以下错误:

Neither the property "expiresAt" nor one of the methods "getExpiresAt()", "expiresAt()", "isExpiresAt()", "hasExpiresAt()", "__get()" exist and have public access in class "PDOneBundle\Entity\User".

为什么?这些方法不应该是从 BaseUser 扩展而来的吗?为什么会出错?

属性 expiresAt 似乎没有 getter : https://github.com/FriendsOfSymfony/FOSUserBundle/blob/master/Model/User.php 我想如果 EasyAdminBundle 需要,您可以轻松地在扩展的 User class 中添加自己的 getter。

class User extends BaseUser
{
    // ...
    public function getExpiresAt() {
        return $this->expiresAt;
    }
    // ...
}

看起来您还可以定义哪些属性 EasyAdminBundle 控件:https://github.com/javiereguiluz/EasyAdminBundle/blob/v1.2.1/Resources/doc/11-configuration-reference.md#advanced-configuration-with-custom-field-configuration