Example #1
0
 /**
  * {@inheritdoc}
  */
 public function fetchLocation($name, array $token = [])
 {
     $namespace = $this->compiler->getNamespace();
     //We can't use slashes to separate view folders
     $view = str_replace($this->options['separator'], '/', $name);
     if (strpos($view, $this->options['nsSeparator']) !== false) {
         //Namespace can be redefined by tag name
         list($namespace, $view) = explode($this->options['nsSeparator'], $view);
         if (empty($namespace)) {
             $namespace = $this->compiler->getNamespace();
         }
     }
     if (!empty($token)) {
         foreach ($token[HtmlTokenizer::TOKEN_ATTRIBUTES] as $attribute => $value) {
             if (in_array($attribute, $this->options['keywords']['namespace'])) {
                 //Namespace can be redefined from attribute
                 $namespace = $value;
             }
             if (in_array($attribute, $this->options['keywords']['view'])) {
                 //Overwriting view
                 $view = $value;
             }
         }
     }
     if ($namespace == 'self') {
         $namespace = $this->compiler->getNamespace();
     }
     return [$namespace, $view];
 }
Example #2
0
 /**
  * {@inheritdoc}
  */
 public function __construct(ViewManager $views, Compiler $compiler, array $options)
 {
     $this->compiler = $compiler;
     $this->options = $options + $this->options;
     if ($this->compiler->getNamespace() != ViewProviderInterface::DEFAULT_NAMESPACE) {
         $this->bundle = $compiler->getNamespace();
     }
     //I18n namespace constructed using view name, view namespace and prefix
     $this->bundle .= '-' . $this->options['prefix'] . str_replace(['/', '\\'], '-', $compiler->getView());
     $this->bundle = trim($this->bundle, '-');
 }