From this document https://docs.phalcon.io/en/latest/reference/dispatching.html#forwarding-to-other-actions
And this example:
<?php
class IndexController extends ControllerBase
{
public function indexAction()
{
$this->tag->setTitle('Home');
parent::initialize();
}
public function page2Action()
{
$this->tag->setTitle('Page 2');
parent::initialize();
}
public function page2aAction()
{
echo 'This is page 2 a content.';
}
public function page3Action($roll = '', $track = '')
{
echo 'hi<br>';
echo $this->dispatcher->getParam('roll') . '<br>';// require defined route.
echo $this->dispatcher->getParam('track') . '<br>';// require defined route.
echo $this->dispatcher->getParam('pagename') . '<br>';// require defined route.
echo '<hr>';
echo $roll . '<br>';
echo $track . '<br>';
echo '<hr>';
// I think this is like hmvc request.
$this->dispatcher->forward(
array(
'controller' => 'index',
'action' => 'page2',
)
);
echo $this->dispatcher->getReturnedValue();// nothing come out.
echo '<hr>';
$this->dispatcher->forward(
array(
'controller' => 'index',
'action' => 'page2a',
)
);
$this->view->disable();
}
}
I can use dispatcher->forward() to get content from page2aAction but not in page2Action. If I want to get page content I must always use echo?