1

Can we redirect controller to another controller in such a way that previous controller continue its working in its execute method and next controller works render the layout at a same time? and after executing it returns the next controller

e.g

public function execute()
{
 //do what ever we want
 return $resultRedirect->setPath('abc/def/jklmno');
}
public function abc()
{
 $resultRedirect->setPath('abc/def/ghi');
}

is this possible?

asked Apr 29, 2019 at 11:31

1 Answer 1

2

Re-direction to another controller is fine and no code will be executed if it not called or included inside the execute()

So, basically you should call that function on your execute() which has re-direction function and so.

For Example :

public function execute()
{
 //do what ever we want
 return $this->abc(); // call internal function then next line won't execute
 return $resultRedirect->setPath('abc/def/jklmno');
}
public function abc()
{
 $resultRedirect->setPath('abc/def/ghi');
}

I could partially understood your requirement and may be I would say re-direction based on certain conditions would help you as far as I guess.

NOTE : Each page have a separate controller.

Hope this helps.

answered Apr 29, 2019 at 11:38
2
  • but after returning to function it won't read next code then it means there is no way i can run 2 controllers at a same time like "it shows to user $resultRedirect->setPath('abc/def/ghi'); controller" and actually executing previous controller work Commented Apr 29, 2019 at 11:42
  • See controller is and action, which has specific functionality to be executed when an specific action is triggered. So for each page has a controller without that you won't be displaying a page @AsadUllah Commented Apr 29, 2019 at 11:46

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.