How to do the following __construct section shown in ZF1 on the fly in ZF2 way?
I have tried $this->headTitle('..');
by ommiting ->view call, but it still fail by throwing:
Zend\ServiceManager\ServiceManager::get was unable to fetch or create an instance for headTitle
public function __construct() { //init is gone
$this->_helper->layout()->setLayout('brand');
$this->HeadTitle($this->title)->setIndent(8);
$this->view->headMeta()->appendName('keywords', $this->keyword)->setIndent(8);
$this->view->headMeta()->appendName('description', $this->description)->setIndent(8);
$this->view->headMeta()->appendName('Language', 'en')->setIndent(8);
$this->view->headMeta()->appendName('dc.title', $this->title)->setIndent(8);
$this->view->headMeta()->appendName('dc.keywords', $this->keyword)->setIndent(8);
$this->view->headMeta()->appendName('dc.description', $this->description)->setIndent(8);
$this->view->headLink()->appendStylesheet('/css/main.css')->setIndent(8);
$this->view->headLink()->appendStylesheet('/jquery/css/custom-theme/jquery-ui-
1.8.20.custom.css')->setIndent(8);
$post = $this->getRequest()->getPost();
$get = $this->getRequest()->getQuery();
}
You could access to 'renderer' object in your action controller:
public function indexAction()
{
$renderer = $this->getServiceLocator()->get('Zend\View\Renderer\PhpRenderer');
$renderer->headTitle('My title');
return new ViewModel();
}