Answer the question
In order to leave comments, you need to log in
How to use Event Listener or Event Subscriber and/or tcnm to refactor the rights checking code?
There is a piece of code that checks the right to delete / update / change status. And I want to reorganize it so that it is not necessary to call checks every time.
Rights check method:
/**
* @param Proposition $proposition
* @param User $user
* @return bool
*/
public function checkAccessPermission(Proposition $proposition, User $user): bool
{
if($proposition->getUser() === $user || $proposition->getVacancy()->getUser() === $user) {
return true;
}
throw new AccessDeniedException();
}
$this->propositionService->checkAccessPermission($proposition, $this->getUser());
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question