Artem Zubkov
Artem Zubkov

Reputation: 559

How to run a controller from a helper. Zend Framework 1.12

I understand that this isn't true way! But tell me, how can I run other module->controller from action helper? Or give me other way!

I have an api module, and need run that api module from helper with prepared request params. Do you have any thoughts about this?

Into an Action_Helper I try to apply this code:

require_once "../../modules/somemodule/controllers/SomeController.php";
$ctrl = new Somemodule_SomeController($request, $response);
$ctrl->run();

But get error:

Fatal error:  require_once(): Failed opening required '../../modules/somemodule/controllers/SomeController.php' (include_path='..') in /path/to/helper/action

SOLUTION

If we ask a question on another

How to run a controller from another controller?

We've got an answer =)
Into an Action Helper

$that = $this->getActionController();
$that->forward("someAction", "someController", "someModule", $params);

Upvotes: 0

Views: 120

Answers (1)

Artem Zubkov
Artem Zubkov

Reputation: 559

If we ask a question on another

How to run a controller from another controller?

We've got an answer =)
Into an Action Helper

$that = $this->getActionController();
$that->forward("someAction", "someController", "someModule", $params);

Upvotes: 1

Related Questions