Exemplo n.º 1
0
 /**
  * Fetch imports from declared location.
  *
  * @param Templater $templater
  * @param mixed     $location
  * @param array     $token
  * @throws TemplaterException
  */
 protected function fetchImports(Templater $templater, $location, array $token)
 {
     //Let's create bundle node
     $bundle = $templater->createNode($location, '', $token);
     /**
      * We expecting to fetch imports located in templater associated with bundle node.
      *
      * @var Templater $bundleTemplater
      */
     $bundleTemplater = $bundle->getSupervisor();
     if (!$bundleTemplater instanceof Templater) {
         throw new TemplaterException("BundleImport must be executed using Templater.", $token);
     }
     //We can fetch all importers from our bundle view
     $this->imports = $bundleTemplater->getImports();
 }
Exemplo n.º 2
0
 /**
  * {@inheritdoc}
  *
  * @throws TemplaterException
  */
 public function __construct(Templater $templater, array $token)
 {
     $attributes = $token[HtmlTokenizer::TOKEN_ATTRIBUTES];
     if (!$templater instanceof TemplateProcessor) {
         throw new TemplaterException("NamespaceImport must be executed using TemplateProcessor.");
     }
     if (strpos($attributes['path'], $templater->getOptions()['nsSeparator']) !== false) {
         //Path includes namespace, we can fetch it regular way
         list($this->namespace, $this->directory) = $templater->fetchLocation($attributes['path'], $token);
     } else {
         $this->namespace = $templater->getCompiler()->getNamespace();
         $this->directory = $attributes['path'];
     }
     $this->directory = rtrim($this->directory, '/*');
     $this->outerNamespace = $attributes['namespace'];
     //Let's generate set of aliases
     $this->buildAliases($templater->getViews(), $templater, $token);
 }
Exemplo n.º 3
0
 /**
  * Create placeholder block (to be injected with inner blocks defined in context).
  *
  * @param string $name
  * @param string $blockID
  * @return string
  */
 protected function createPlaceholder($name, &$blockID)
 {
     $blockID = $name . '-' . $this->templater->uniquePlaceholder();
     //Short block declaration syntax
     return '${' . $blockID . '}';
 }
Exemplo n.º 4
0
 /**
  * {@inheritdoc}
  */
 public function __construct(Templater $templater, array $token)
 {
     $attributes = $token[HtmlTokenizer::TOKEN_ATTRIBUTES];
     $this->location = $templater->fetchLocation($attributes['path'], $token);
     $this->alias = $attributes['as'];
 }