我目前在 Zend 2 的库中工作,其中包括渲染视图脚本。渲染工作正常,我还可以在视图脚本中使用任何其他帮助程序,但是 basePath() 帮助程序抛出异常并显示消息:
No base path provided
我已经尝试在配置中设置 basePath,但它只是在控制器呈现的视图脚本中发生变化。如果它是相关的,这里是呈现视图的代码:
// file: /vendor/mate/library/mate/Group/Functions/GetHtml.php
// $templateDir is either directing to /module/Application/view/group/<name>.phtml
// or to /vendor/mate/library/mate/view/group/<name>.phtml
$map = new Resolver\TemplateMapResolver(array(
'group/'.$type => $templateDir,
));
$stack = new Resolver\TemplatePathStack(array(
'script_paths' => array(
$viewDir,
)
));
$resolver->attach($map) // this will be consulted first
->attach($stack);
$groupModel = new ViewModel(array(
'elements' => $this->getGroup()->toArray(),
'groupElement' => $groupElement,
));
$groupModel->setTemplate('group/'.$type);
$groupHtml = $renderer->render($groupModel);
有谁知道如何让 basePath 在我的视图脚本中工作?