public function renderLayoutSegments(MvcEvent $e)
    {
        /* @var $viewModel ViewModel */
        $viewModel = $e->getViewModel();

        // skip if current ViewModel is of expected type
        if ('Zend\View\Model\ViewModel' != get_class($viewModel)) {
            return;
        }

        /** @var AggregateResolver $resolver */
        $resolver = $e->getApplication()->getServiceManager()->get(
            'ViewResolver'
        );

        // loop through layout segments
        foreach ($this->layoutSegments as $segment) {

            // skip if layout segment does not exist
            if (!$resolver->resolve('layout/' . $segment)) {
                continue;
            }

            // add an additional header segment to layout
            $header = new ViewModel();
            $header->setTemplate('layout/' . $segment);
            $viewModel->addChild($header, $segment);
        }
    }
public function renderLayoutSegments(MvcEvent $e)
    {
        /* @var $viewModel ViewModel */
        $viewModel = $e->getViewModel();

        // skip if current ViewModel is of expected type
        if ('Zend\View\Model\ViewModel' != get_class($viewModel)) {
            return;
        }

        /** @var AggregateResolver $resolver */
        $resolver = $e->getApplication()->getServiceManager()->get(
            'ViewResolver'
        );

        // loop through layout segments
        foreach ($this->layoutSegments as $segment) {

            // skip if layout segment does not exist
            if (!$resolver->resolve('layout/' . $segment)) {
                continue;
            }

            // add an additional header segment to layout
            $header = new ViewModel();
            $header->setTemplate('layout/' . $segment);
            $viewModel->addChild($header, $segment);
        }
    }
public function renderLayoutSegments ( MvcEvent $ e ) { /* @var $viewModel ViewModel */ $ viewModel = $ e -> getViewModel ( ) ; // skip if current ViewModel is of expected type if ( 'Zend\View\Model\ViewModel' != get_class ( $ viewModel ) ) { return ; } /** @var AggregateResolver $resolver */ $ resolver = $ e -> getApplication ( ) -> getServiceManager ( ) -> get ( 'ViewResolver' ) ; // loop through layout segments foreach ( $ this -> layoutSegments as $ segment ) { // skip if layout segment does not exist if ( ! $ resolver -> resolve ( 'layout/' . $ segment ) ) { continue ; } // add an additional header segment to layout $ header = new ViewModel ( ) ; $ header -> setTemplate ( 'layout/' . $ segment ) ; $ viewModel -> addChild ( $ header , $ segment ) ; } }
Listen to the "render" event and render additional layout segments

@param  MvcEvent $e

@return null
Listen to the render event and render additional layout segments