G
G
grabbee2020-05-14 12:28:45
symfony
grabbee, 2020-05-14 12:28:45

Where to take out "non-specific" logic from the controller?

For example.

The controller gives some resource on request. Now without authorization.
Then authorization is needed, and it is proposed to take it out in general in `Voters`. In this case, the authorization logic is non-specific to a request to obtain a resource. She may or may not. That's how I understand non-specificity in this context.

And so, for example, we needed to add a condition - how many resources are in the database. And if there are less than 10 of them - do not give the resource. For example. That is, it is again non-specific logic. And it does not seem to be necessary to place it either in the service or in the controller. And it's logical to take out the same as the authorization logic in `Voters` - only in something else.

What is this "something else" called? How to do it?

---

PS: Now I've thought of adding my own "interceptor" annotation of the request to the controller on the onKernelController event . And make all such checks in it. Avoiding mixing this logic of additional checks with the logic of services and controllers related to the resource. How to call it, I do not know.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question