I have this User entity extends from 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
}
I am using also EasyAdminBundle and any time I try to add a new user from EasyAdmin I got the following error:
Neither the property "expiresAt" nor one of the methods "getExpiresAt()", "expiresAt()", "isExpiresAt()", "hasExpiresAt()", "__get()" exist and have public access in class "PDOneBundle\Entity\User".
Why? It is not supposed that those methods are extended from BaseUser? Why the error?
It doesn't look like there is a getter for property expiresAt
: https://github.com/FriendsOfSymfony/FOSUserBundle/blob/master/Model/User.php
I guess you could easily add your own getter in your extended User
class if EasyAdminBundle
requires it.
class User extends BaseUser
{
// ...
public function getExpiresAt() {
return $this->expiresAt;
}
// ...
}
Looks like you could also define which properties EasyAdminBundle
controls : https://github.com/javiereguiluz/EasyAdminBundle/blob/v1.2.1/Resources/doc/11-configuration-reference.md#advanced-configuration-with-custom-field-configuration