A
A
Andrey Pushkin2020-12-31 19:19:04
symfony
Andrey Pushkin, 2020-12-31 19:19:04

Does doctrine or symfony have analogue of laravel's GlobalScope?

I have a division into workspace in my application.
Each user has access only to the workspace to which he is attached. The workspace itself is stored in the user.
And when I need to get, for example, a list of projects, but in general, when I access each entity, I need to select initially by workspace.

$this->repo->createQueryBuilder('m')
        ->select('*')
        ->where('t.workspace_id = :id')
        ->setParameter(':id', $user->id)
        ->getQuery();

I read the question voiced here and did not find the answer for myself there. Laravel has a cool thing - globalScope, which I can use to automate the selection. What about symfony?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
Flying, 2020-12-31
@Flying

I didn’t write on Laravel, but judging by the documentation, this is some kind of analogue of an additional filter that can be hung on a request. If I'm right, then the closest analogue is filters .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question