public function createService(ServiceLocatorInterface $serviceLocator)
    {
        // handle configuration
        $config = $serviceLocator->get('Config');
        $viewConfig = isset($config['view']) ? $config['view'] : array();

        $className = isset($viewConfig['classname']) ? $viewConfig['classname'] : 'HumusMvc\View\View';
        $view = new $className($viewConfig);
        if (!$view instanceof View) {
            throw new InvalidArgumentException('View object must extend HumusMvc\View\View');
        }
        $view->setHelperPluginManager($serviceLocator->get('ViewHelperManager'));

        if (isset($viewConfig['doctype'])) {
            $view->doctype()->setDoctype(strtoupper($viewConfig['doctype']));
            if (isset($viewConfig['charset']) && $view->doctype()->isHtml5()) {
                $view->headMeta()->setCharset($viewConfig['charset']);
            }
        }

        if (isset($viewConfig['contentType'])) {
            $view->headMeta()->appendHttpEquiv('Content-Type', $viewConfig['contentType']);
        }

        if (isset($viewConfig['assign']) && is_array($viewConfig['assign'])) {
            $view->assign($viewConfig['assign']);
        }

        if (isset($viewConfig['useViewRenderer']) && true === (bool) $viewConfig['useViewRenderer']) {
            $viewRenderer = ControllerActionHelper::getStaticHelper('viewRenderer');
            $viewRenderer->setView($view);
        }
        return $view;
    }
public function createService(ServiceLocatorInterface $serviceLocator)
    {
        // handle configuration
        $config = $serviceLocator->get('Config');
        $viewConfig = isset($config['view']) ? $config['view'] : array();

        $className = isset($viewConfig['classname']) ? $viewConfig['classname'] : 'HumusMvc\View\View';
        $view = new $className($viewConfig);
        if (!$view instanceof View) {
            throw new InvalidArgumentException('View object must extend HumusMvc\View\View');
        }
        $view->setHelperPluginManager($serviceLocator->get('ViewHelperManager'));

        if (isset($viewConfig['doctype'])) {
            $view->doctype()->setDoctype(strtoupper($viewConfig['doctype']));
            if (isset($viewConfig['charset']) && $view->doctype()->isHtml5()) {
                $view->headMeta()->setCharset($viewConfig['charset']);
            }
        }

        if (isset($viewConfig['contentType'])) {
            $view->headMeta()->appendHttpEquiv('Content-Type', $viewConfig['contentType']);
        }

        if (isset($viewConfig['assign']) && is_array($viewConfig['assign'])) {
            $view->assign($viewConfig['assign']);
        }

        if (isset($viewConfig['useViewRenderer']) && true === (bool) $viewConfig['useViewRenderer']) {
            $viewRenderer = ControllerActionHelper::getStaticHelper('viewRenderer');
            $viewRenderer->setView($view);
        }
        return $view;
    }
public function createService ( ServiceLocatorInterface $ serviceLocator ) { // handle configuration $ config = $ serviceLocator -> get ( 'Config' ) ; $ viewConfig = isset ( $ config [ 'view' ] ) ? $ config [ 'view' ] : array ( ) ; $ className = isset ( $ viewConfig [ 'classname' ] ) ? $ viewConfig [ 'classname' ] : 'HumusMvc\View\View' ; $ view = new $ className ( $ viewConfig ) ; if ( ! $ view instanceof View ) { throw new InvalidArgumentException ( 'View object must extend HumusMvc\View\View' ) ; } $ view -> setHelperPluginManager ( $ serviceLocator -> get ( 'ViewHelperManager' ) ) ; if ( isset ( $ viewConfig [ 'doctype' ] ) ) { $ view -> doctype ( ) -> setDoctype ( strtoupper ( $ viewConfig [ 'doctype' ] ) ) ; if ( isset ( $ viewConfig [ 'charset' ] ) && $ view -> doctype ( ) -> isHtml5 ( ) ) { $ view -> headMeta ( ) -> setCharset ( $ viewConfig [ 'charset' ] ) ; } } if ( isset ( $ viewConfig [ 'contentType' ] ) ) { $ view -> headMeta ( ) -> appendHttpEquiv ( 'Content-Type' , $ viewConfig [ 'contentType' ] ) ; } if ( isset ( $ viewConfig [ 'assign' ] ) && is_array ( $ viewConfig [ 'assign' ] ) ) { $ view -> assign ( $ viewConfig [ 'assign' ] ) ; } if ( isset ( $ viewConfig [ 'useViewRenderer' ] ) && true === ( bool ) $ viewConfig [ 'useViewRenderer' ] ) { $ viewRenderer = ControllerActionHelper :: getStaticHelper ( 'viewRenderer' ) ; $ viewRenderer -> setView ( $ view ) ; } return $ view ; }
Create view service

@param ServiceLocatorInterface $serviceLocator
@return View
@throws InvalidArgumentException
Create view service