O
O
Orbb2018-06-21 17:39:33
Yii
Orbb, 2018-06-21 17:39:33

How to make friends with modules in Yii2?

There is an api module, there is a user module, how can you access the user from the api, including his actions?
The idea is: the user lives separately with his own structure, closed from the outside, when you need to pass verification, register, get rights - we turn to him, do everything there (generate tokens, record the session, enter into the database and everything else), give it back to another module. Can I somehow get something more useful than information about the module through Yii::$app->getModule('user')?
I just can’t catch up on how to get actions from controllers otherwise than by referring to the url (I drove it with a curl, but it’s a game).

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Mykola, 2018-06-21
@iSensetivity

Make all the above services.

M
Maxim Timofeev, 2018-06-21
@webinar

Your problem is that you have something in your controller that shouldn't be there. Take out what you need in a separate object or component and use it. The action, by the way, can also be made a separate class, just for reuse. But it seems to me that you have a problem in the wrong architecture and a thick controller.
They must be separate classes made for this:
https://www.yiiframework.com/doc/guide/2.0/en/stru...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question