我正在创建一个全局函数,它将初始化我的ZF2应用程序的所有全局和css文件。来自Controller目前的代码看起来像这样
/**
** Set Global media files for Application
** Rest can be initialized in controllers
**/
private function setMedia() {
$this->viewManager=new ViewModel;
$this->viewManager->headLink()
->appendStylesheet(_CB_ASSETS_PATH_.'/css/docker.css', 'all', 'IE');
return $this->viewManager;
}
但问题是我收到了错误
Fatal error: Call to undefined method Zend\View\Model\ViewModel::headLink() in C:\Apache24\htdocs\cartbiz\module\Front\src\Front\Model\FrontCore.php on line 59
任何帮助都会得到极大的赞赏
谢谢!
答案 0 :(得分:0)
就是这个......
$this->getServiceLocator()->get('viewhelpermanager')->get('HeadLink')->appendStylesheet(_CB_ASSETS_PATH_ . '/css/docker.css', 'all', 'IE');