-
Notifications
You must be signed in to change notification settings - Fork 19
Blameable and decoupled user entity and userinterface'd class #12
Description
Hi, I'm using decoupled Entity and Security user following this article https://stovepipe.systems/post/decoupling-your-security-user
Now my entity looks like:
class Batch {
// ....
/**
* @var User
*
* @Gedmo\Blameable(on="create")
* @ORM\ManyToOne(targetEntity="User")
*/
private $createdBy;
//...
where App\Entity\User is just an Entity and class App\Security\User\SecurityUser implements actual UserInterface.
Now, using Blameable, when I try to save the entity with the current user in related field, it produces error:
The class 'App\Security\User\SecurityUser' was not found in the chain configured namespaces App\Entity
Which is because of this line of code:
if (null !== $token && $this->authorizationChecker->isGranted('IS_AUTHENTICATED_REMEMBERED')) {
$this->blameableListener->setUserValue($token->getUser());
}
$token->getUser() returns an object of class App\Security\User\SecurityUser not the Entity.
Can you please update the Blameable to inject and query Symfony\Bridge\Doctrine\Security\User\UserLoaderInterface or use Symfony\Component\Security\Core\User\UserProviderInterface so that User entity'd be loaded from the database instead (of course if $token->getUser() returns not an entity).