src/ZfcTwig/View/HelperPluginManagerFactory.php
public function createService(ServiceLocatorInterface $serviceLocator)
    {
        /** @var \ZfcTwig\moduleOptions $options */
        $options        = $serviceLocator->get('ZfcTwig\ModuleOptions');
        $managerOptions = $options->getHelperManager();
        $managerConfigs = isset($managerOptions['configs']) ? $managerOptions['configs'] : array();

        $baseManager = $serviceLocator->get('ViewHelperManager');
        $twigManager = new HelperPluginManager(new Config($managerOptions));
        $twigManager->setServiceLocator($serviceLocator);
        $twigManager->addPeeringServiceManager($baseManager);

        foreach ($managerConfigs as $configClass) {
            if (is_string($configClass) && class_exists($configClass)) {
                $config = new $configClass;

                if (!$config instanceof ConfigInterface) {
                    throw new Exception\RuntimeException(
                        sprintf(
                            'Invalid service manager configuration class provided; received "%s",
                                expected class implementing %s',
                            $configClass,
                            'Zend\ServiceManager\ConfigInterface'
                        )
                    );
                }

                $config->configureServiceManager($twigManager);
            }
        }

        return $twigManager;
    }
public function createService(ServiceLocatorInterface $serviceLocator)
    {
        /** @var \ZfcTwig\moduleOptions $options */
        $options        = $serviceLocator->get('ZfcTwig\ModuleOptions');
        $managerOptions = $options->getHelperManager();
        $managerConfigs = isset($managerOptions['configs']) ? $managerOptions['configs'] : array();

        $baseManager = $serviceLocator->get('ViewHelperManager');
        $twigManager = new HelperPluginManager(new Config($managerOptions));
        $twigManager->setServiceLocator($serviceLocator);
        $twigManager->addPeeringServiceManager($baseManager);

        foreach ($managerConfigs as $configClass) {
            if (is_string($configClass) && class_exists($configClass)) {
                $config = new $configClass;

                if (!$config instanceof ConfigInterface) {
                    throw new Exception\RuntimeException(
                        sprintf(
                            'Invalid service manager configuration class provided; received "%s",
                                expected class implementing %s',
                            $configClass,
                            'Zend\ServiceManager\ConfigInterface'
                        )
                    );
                }

                $config->configureServiceManager($twigManager);
            }
        }

        return $twigManager;
    }
Create service

@param ServiceLocatorInterface $serviceLocator
@throws \Zend\View\Exception\RuntimeException
@return mixed