我正在使用Zend Framework描述,我正在尝试自定义标题标记,如ZF2 documetation推荐,但我遇到了这个错误:
未捕获的Zend \ ServiceManager \ Exception \ ServiceNotFoundException: 无法将服务“viewHelperManager”解析为工厂;你是 你确定在配置期间提供了它吗?在 /var/www/html/basketmetrics/vendor/zendframework/zend-servicemanager/src/ServiceManager.php:681 堆栈跟踪:#0 /var/www/html/basketmetrics/vendor/zendframework/zend-servicemanager/src/ServiceManager.php(757): 的Zend \的ServiceManager \ ServiceManager-> getFactory( 'viewHelperManag ...')
1 /var/www/html/basketmetrics/vendor/zendframework/zend-servicemanager/src/ServiceManager.php(200): Zend \ ServiceManager \ ServiceManager-> doCreate('viewHelperManag ...')#2 /var/www/html/basketmetrics/module/Stats/src/Module.php(43): Zend \ ServiceManager \ ServiceManager-> get('viewHelperManag ...')#3 /var/www/html/basketmetrics/vendor/zendframework/zend-eventmanager/src/EventManager.php(322): Stats \ Module-> setLayoutTitle(Object(Zend \ Mvc \ MvcEvent))#4 /var/www/html/basketmetrics/vendor/zendframework/zend-eventmanager/src/EventManager.php(171): Zend \ EventManager \ E in /var/www/html/basketmetrics/vendor/zendframework/zend-servicemanager/src/ServiceManager.php 在第681行
这是我在Module.php上的代码
namespace Stats;
class Module
{
const VERSION = '3.0.2';
public function getConfig()
{
return include __DIR__ . '/../config/module.config.php';
}
/**
* @param \Zend\Mvc\MvcEvent $e The MvcEvent instance
* @return void
*/
public function onBootstrap($e)
{
// Register a render event
$app = $e->getParam('application');
$app->getEventManager()->attach('render', array($this, 'setLayoutTitle'));
}
/**
* @param \Zend\Mvc\MvcEvent $e The MvcEvent instance
* @return void
*/
public function setLayoutTitle($e)
{
$matches = $e->getRouteMatch();
$action = $matches->getParam('action');
$controller = $matches->getParam('controller');
$module = __NAMESPACE__;
$siteName = 'BasketMetrics';
// Getting the view helper manager from the application service manager
$viewHelperManager = $e->getApplication()->getServiceManager()->get('viewHelperManager');
// Getting the headTitle helper from the view helper manager
$headTitleHelper = $viewHelperManager->get('headTitle');
// Setting a separator string for segments
$headTitleHelper->setSeparator(' - ');
// Setting the action, controller, module and site name as title segments
$headTitleHelper->append($action);
$headTitleHelper->append($controller);
$headTitleHelper->append($module);
$headTitleHelper->append($siteName);
}
}
我不知道如果我做错了,或者我不能像ZF2那样做。
元标记“描述”如何自定义?
答案 0 :(得分:0)
-> get(' V iewHelperManager') 大写字母