I'm using Zend Framework description and I'm trying to customize title tag like ZF2 documetation recommends, but I've got this error:
Uncaught Zend\ServiceManager\Exception\ServiceNotFoundException: Unable to resolve service "viewHelperManager" to a factory; are you certain you provided it during configuration? in /var/www/html/basketmetrics/vendor/zendframework/zend-servicemanager/src/ServiceManager.php:681 Stack trace: #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 on line 681
This is my code on 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);
}
}
I don't know If I'm doing something wrong, or if I cannot do it like in ZF2.
And meta tag "description" how can I customize it?