php - Phalcon stop view from echoing after dispatch()

I have the following code below which works as I suppose it should. I would like to know if there is a way to just return the view contents without actually showing the view on the browser. At the moment, the dispatcher runs and targets the controller/action which has a view associated with that action. At the end of the dispatch, that view echoes in the browser.
I would like to be able to run this method multiple times with different contoller/actions and just collect the view contents in order to finally send them to another view where they will be combined.
Collecting the contents succeed but the ultimate view cant be displayed as the page ends up showing the view of the last action the dispatch hit. Any help in stopping that view from actually loading?
$dispatcher = $application->dispatcher;
$dispatcher->setNamespaceName(xxxxx);
$dispatcher->setModuleName(xxxxx);
$dispatcher->setControllerName(xxxxx);
$dispatcher->setActionName(xxxxx);
/**
* @var \Phalcon\Mvc\ViewInterface $view
*/
$view = $dispatcher->dispatch()->view;
$view->start();
$view->render(
$dispatcher->getControllerName(),
$dispatcher->getActionName(),
$dispatcher->getParams()
);
$view->finish();
return $view->getContent();
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: target class [commandmakecommand] does not exist.
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.