S
S
Stanislav Shendakov2020-04-28 10:14:30
symfony
Stanislav Shendakov, 2020-04-28 10:14:30

Easy admin. How to check the path?

Good afternoon.

I am mastering Symfony 5. I am making an admin panel based on Easy admin. When you switch to viewing the entity, the address bar in the browser looks like this:
sf/admin/?entity=Product&action=list&menuIndex=2&s...
I.e. if Product is replaced by User, there will be a transition to the User entity. Moreover, you can even enter:
sf/admin/?entity=Product&action=show&menuIndex=2&s...
B by changing show to edit, you can easily edit your data. The system has a system of roles, so such actions are not allowed. Question: where and how is the best way to check the address bar parameters, analyze them and, if necessary, make a redirect. Or is Easy admin not very suitable for such conditions and does it make sense to switch to Sonata? Thanks in advance.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Fedorov, 2020-04-28
@Maksclub

EasyAdmin controllers are quite simple, you just inherit from EasyAdminController and name your controller like so: EntityName+ Controller, so for User it will be UserController.
And for your controllers, as elsewhere in Symfony, you can use your own roles, like this:

/**
 * @Security("is_granted('ROLE_CAN_EDIT_USER')")
 */
class UserController extends EasyAdminController
Read more:
Annotation Security
Symfony Uses Voters
Also check out EasyAdmin: Security and Permissions¶ , especially aboutitem_permission

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question