我是zend-framework 2的首发.如果我需要创建一个链接view.phtml,使用这个:
$this->url('router',array())
Run Code Online (Sandbox Code Playgroud)
现在我需要在控制器中创建一个链接并保存到数据库.任何的想法?
Moh*_*ibi 15
试试这个:
public function someAction()
{
//codes
//use url plugin in controller
$link = $this->url()->fromRoute('router', array());
//or use ViewHelperManager in controller or other place that you have ServiceManager
$link = $this->getServiceLocator()->get('ViewHelperManager')->get('url')->__invoke('router',array());
//codes
}
Run Code Online (Sandbox Code Playgroud)