如何使用headLink helper从控制器中包含css和js文件


How to include css and js files from controller using headLink helper

我正在创建一个全局函数,将初始化所有全局和css文件为我的ZF2应用程序从控制器当前代码看起来像这样

    /**
    ** 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

任何帮助都非常感谢

谢谢!

Just this…

$this->getServiceLocator()->get('viewhelpermanager')->get('HeadLink')->appendStylesheet(_CB_ASSETS_PATH_ . '/css/docker.css', 'all', 'IE');