public function getContent() { $info = new \SplFileInfo($this->file); $renderer = new PhpRenderer(); $stack = new TemplatePathStack(); $stack->addPath($info->getPath()); $stack->setDefaultSuffix(pathinfo($this->file, PATHINFO_EXTENSION)); $renderer->setResolver($stack); return $renderer->render($info->getBasename()); }
public function createService(ServiceLocatorInterface $serviceLocator) { /* @var $config ModuleOptions */ $config = $serviceLocator->get('ZendSmarty\\ModuleOptions'); /* @var $orig TemplatePathStack */ $orig = $serviceLocator->get('ViewTemplatePathStack'); $instance = new TemplatePathStack(); $instance->addPaths($orig->getPaths()->toArray()); $instance->setDefaultSuffix($config->suffix); return $instance; }
/** * Create service * * @param ServiceLocatorInterface $serviceLocator * @return mixed */ public function createService(ServiceLocatorInterface $serviceLocator) { $config = $serviceLocator->get('Config'); $templatePathStack = new ViewResolver\TemplatePathStack(); if (is_array($config) && isset($config['view_manager'])) { $config = $config['view_manager']; if (is_array($config) && isset($config['template_path_stack'])) { $templatePathStack->addPaths($config['template_path_stack']); } if (is_array($config) && isset($config['smarty_default_suffix'])) { $templatePathStack->setDefaultSuffix($config['smarty_default_suffix']); } } return $templatePathStack; }
/** * Create the template path stack view resolver * * Creates a Zend\View\Resolver\TemplatePathStack and populates it with the * ['view_manager']['template_path_stack'] and sets the default suffix with the * ['view_manager']['default_template_suffix'] * * @param ContainerInterface $container * @param string $name * @param null|array $options * @return ViewResolver\TemplatePathStack */ public function __invoke(ContainerInterface $container, $name, array $options = null) { $config = $container->get('config'); $templatePathStack = new ViewResolver\TemplatePathStack(); if (is_array($config) && isset($config['view_manager'])) { $config = $config['view_manager']; if (is_array($config)) { if (isset($config['template_path_stack'])) { $templatePathStack->addPaths($config['template_path_stack']); } if (isset($config['default_template_suffix'])) { $templatePathStack->setDefaultSuffix($config['default_template_suffix']); } } } return $templatePathStack; }