Symfony: как проверить, предоставлен ли другой контроллер ⇐ Php
-
Anonymous
Symfony: как проверить, предоставлен ли другой контроллер
e.g. I have a Show action for my Categories, and there is an "actions" property I want to provide the frontend with the list of actions that the current logged in user can do on this entity (e.g. ["edit", "delete"]).
In the backend I want to simply give a list of Controllers (since I use __invoke, just passing the class name should be enough: e.g. ["edit" => CategoryEditController::class, "delete" => CategoryDeleteController::class]) to a function which tells me whether that controller is accessible for the user or not (e.g. ["edit" => true, "delete" => false])
I haven't figured out yet how I can check another class's IsGranted which is the crucial issue I'm facing. Does anyone have an idea?
Also need to consider, IsGranted could not just be a string but an expression and also contain a subject.
Источник: https://stackoverflow.com/questions/781 ... is-granted
e.g. I have a Show action for my Categories, and there is an "actions" property I want to provide the frontend with the list of actions that the current logged in user can do on this entity (e.g. ["edit", "delete"]).
In the backend I want to simply give a list of Controllers (since I use __invoke, just passing the class name should be enough: e.g. ["edit" => CategoryEditController::class, "delete" => CategoryDeleteController::class]) to a function which tells me whether that controller is accessible for the user or not (e.g. ["edit" => true, "delete" => false])
I haven't figured out yet how I can check another class's IsGranted which is the crucial issue I'm facing. Does anyone have an idea?
Also need to consider, IsGranted could not just be a string but an expression and also contain a subject.
Источник: https://stackoverflow.com/questions/781 ... is-granted
Мобильная версия