P
P
Puganov2015-11-17 19:30:46
Yii
Puganov, 2015-11-17 19:30:46

Inherit Yii2 controller?

I am changing, I have already asked a similar question, but not in detail - and of course I did not receive a proper answer.
There is ONE controller ' main '
There are 2 roles that use this controller.
1. The role of the employee
2. The role of the field employee
The task is as follows:
Both roles are loaded by one controller, but the actions of the roles are different, and the action actions are different for both roles. Model naturally in action are loaded different.
It turns out that I need to break this controller into sub-controllers with the necessary actions.
How can I do this in Yii2?
Also, for clarification:
MainController Employee
role:
actionIndex, actionIssued,actionNew
Model app
Field worker role:
actionIndex, actionIssuedHome, actionNewHome
Model appHome
Hope it helps

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Andrew, 2015-11-17
@R0dger

I'll write again...
you have 1 controller.. check what role you have.. and call this or that code..
respectively, the code can be taken into the model.. and only return data from it... and display them accordingly. ..
everything seems to be simple, what confuses you or what is not clear to you?
do actionNew (for BOTH ROLES)
then check for the role .. and then build the logic .. what don't you like here?

P
Puganov, 2015-11-18
@Puganov

Is it possible to inherit controllers inside a global controller?
Depending on the current role, make friends inside the global controller - a subcontroller. But for the global to receive all the actions of the subcontroller?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question