Hi, I'm trying to port old Nette 2.0.4 code to 3.x.
Inside a form handler “handleSave()” I found the following code that creates a subrequest to another module:
// process subreq $request = new \Nette\Application\Request(':Api:Queue', 'POST', $params, $post, $files); $presenter = new \ApiModule\QueuePresenter($this->getContext()); $response = $presenter->run($request); $this->flashMessage($response->getSource());
This called the a presenter class which is also available as HTTP Rest API call. The result is displayed with a flashMessage.
However, this code doesn't work in Nette 3.0.
Any idea on how to fix it? Or is there another way to do a subrequest to another mode?
- David Matějka
- Moderator | 6405
It is better to move the logic from the presenter to some service and call this service instead.
But if you really want to call the presenter, you have to create the
/** @var \Nette\Application\IPresenterFactory @inject public $presenterFactory; // .... $presenter = $this->presenterFactory->createPresenter('Api:Queue');