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 the template map view resolver
  *
  * Creates a Zend\View\Resolver\TemplatePathStack and populates it with the
  * ['view_manager']['template_path_stack']
  *
  * @param  ServiceLocatorInterface $serviceLocator
  * @return ViewResolver\TemplatePathStack
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $config = $serviceLocator->get('Config');
     $stack = array();
     if (is_array($config) && isset($config['view_manager'])) {
         $config = $config['view_manager'];
         if (is_array($config) && isset($config['template_path_stack'])) {
             $stack = $config['template_path_stack'];
         }
     }
     $templatePathStack = new ViewResolver\TemplatePathStack();
     $templatePathStack->addPaths($stack);
     return $templatePathStack;
 }
 /**
  * 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;
 }
Exemple #5
0
 /**
  * Instantiates and configures the renderer's resolver
  *
  * @return ViewAggregateResolver
  */
 public function getResolver()
 {
     if ($this->resolver) {
         return $this->resolver;
     }
     $map = array();
     if (isset($this->config['template_map'])) {
         $map = $this->config['template_map'];
     }
     $templateMapResolver = new ViewResolver\TemplateMapResolver($map);
     $stack = array();
     if (isset($this->config['template_path_stack'])) {
         $stack = $this->config['template_path_stack'];
     }
     $templatePathStack = new ViewResolver\TemplatePathStack();
     $templatePathStack->addPaths($stack);
     $this->resolver = new ViewResolver\AggregateResolver();
     $this->resolver->attach($templateMapResolver);
     $this->resolver->attach($templatePathStack);
     $this->services->setService('ViewTemplateMapResolver', $templateMapResolver);
     $this->services->setService('ViewTemplatePathStack', $templatePathStack);
     $this->services->setService('ViewResolver', $this->resolver);
     $this->services->setAlias('Zend\\View\\Resolver\\TemplateMapResolver', 'ViewTemplateMapResolver');
     $this->services->setAlias('Zend\\View\\Resolver\\TemplatePathStack', 'ViewTemplatePathStack');
     $this->services->setAlias('Zend\\View\\Resolver\\AggregateResolver', 'ViewResolver');
     $this->services->setAlias('Zend\\View\\Resolver\\ResolverInterface', 'ViewResolver');
     return $this->resolver;
 }