/** * Create service * * @param ServiceLocatorInterface $serviceLocator * @return mixed */ public function createService(ServiceLocatorInterface $serviceLocator) { /** @var \GkSmarty\ModuleOptions $options */ $options = $serviceLocator->get('GkSmarty\\ModuleOptions'); $smarty = new \Smarty(); $smarty->setCompileDir($options->getCompileDir()); $smarty->setCacheDir($options->getCacheDir()); // set Smarty engine options foreach ($options->getSmartyOptions() as $key => $value) { $setter = 'set' . str_replace(' ', '', ucwords(str_replace('_', ' ', $key))); if (method_exists($smarty, $setter)) { $smarty->{$setter}($value); } elseif (property_exists($smarty, $key)) { $smarty->{$key} = $value; } } $renderer = new SmartyRenderer($serviceLocator->get('Zend\\View\\View'), $smarty, $serviceLocator->get('GkSmartyResolver')); $renderer->setHelperPluginManager($serviceLocator->get('GkSmartyHelperPluginManager')); return $renderer; }