Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blameable and decoupled user entity and userinterface'd class #2014

Closed
danaki opened this issue May 15, 2019 · 4 comments
Closed

Blameable and decoupled user entity and userinterface'd class #2014

danaki opened this issue May 15, 2019 · 4 comments

Comments

@danaki
Copy link

danaki commented May 15, 2019

Hi, I'm using decoupled Entity and security user like it's described here https://stovepipe.systems/post/decoupling-your-security-user

The reason for that is that I want to keep domain separated following DDD principles.

Now my entity looks like:

class Batch {
// ....
    /**
     * @var Employee
     *
     * @Gedmo\Blameable(on="create")
     * @ORM\ManyToOne(targetEntity="Employee")
     */
    private $createdBy;
//...

while class 'App\Security\User\SecurityUser' implements actual UserInterface.

When I try to save the entity, it produces an 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. Is it possible to override this behavior introducing a configuration option?

@AkenRoberts
Copy link
Member

Hi @danaki, sorry for the lack of attention here.

That code is actually part of StofDoctrineExtensionsBundle, so we can't change that within this library.

You should be able to override the listener class and customize it to suit your setup.

@AkenRoberts
Copy link
Member

@danaki Since there hasn't been any activity for quite a while, I will assume you have resolved your issue. Please update us or open a new issue if you feel there is a problem with Doctrine Extensions itself. Thank you!

@danaki
Copy link
Author

danaki commented Jan 2, 2020

Ok, I'll fill the issue in StofDoctrineExtensionsBundle because it's still actual.

@danaki
Copy link
Author

danaki commented Jan 2, 2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants