setContext() публичный Метод

public setContext ( $context )
Пример #1
0
 /**
  * New node is found.
  * @return bool
  */
 public function nodeOpened(MacroNode $node)
 {
     list($begin, $end, $attr) = $this->macros[$node->name];
     $node->isEmpty = !$end;
     if ($attr && $node->prefix === $node::PREFIX_NONE) {
         $node->isEmpty = TRUE;
         $this->compiler->setContext(Latte\Compiler::CONTEXT_DOUBLE_QUOTED_ATTR);
         $res = $this->compile($node, $attr);
         if ($res === FALSE) {
             return FALSE;
         } elseif (!$node->attrCode) {
             $node->attrCode = "<?php {$res} ?>";
         }
         $this->compiler->setContext(NULL);
     } elseif ($begin) {
         $res = $this->compile($node, $begin);
         if ($res === FALSE || $node->isEmpty && $node->prefix) {
             return FALSE;
         } elseif (!$node->openingCode) {
             $node->openingCode = "<?php {$res} ?>";
         }
     } elseif (!$end) {
         return FALSE;
     }
 }
Пример #2
0
 /**
  * New node is found.
  * @return bool
  */
 public function nodeOpened(MacroNode $node)
 {
     list($begin, $end, $attr) = $this->macros[$node->name];
     $node->isEmpty = !$end;
     if ($node->modifiers && (!$begin || is_string($begin) && strpos($begin, '%modify') === FALSE) && (!$end || is_string($end) && strpos($end, '%modify') === FALSE) && (!$attr || is_string($attr) && strpos($attr, '%modify') === FALSE)) {
         throw new Latte\CompileException("Modifiers are not allowed in {{$node->name}}");
     }
     if ($node->args && (!$begin || is_string($begin) && strpos($begin, '%node') === FALSE) && (!$end || is_string($end) && strpos($end, '%node') === FALSE) && (!$attr || is_string($attr) && strpos($attr, '%node') === FALSE)) {
         throw new Latte\CompileException("Arguments are not allowed in {{$node->name}}");
     }
     if ($attr && $node->prefix === $node::PREFIX_NONE) {
         $node->isEmpty = TRUE;
         $this->compiler->setContext(Latte\Compiler::CONTEXT_QUOTED_ATTRIBUTE);
         $res = $this->compile($node, $attr);
         if ($res === FALSE) {
             return FALSE;
         } elseif (!$node->attrCode) {
             $node->attrCode = "<?php {$res} ?>";
         }
         $this->compiler->setContext(NULL);
     } elseif ($begin) {
         $res = $this->compile($node, $begin);
         if ($res === FALSE || $node->isEmpty && $node->prefix) {
             return FALSE;
         } elseif (!$node->openingCode) {
             $node->openingCode = "<?php {$res} ?>";
         }
     } elseif (!$end) {
         return FALSE;
     }
 }
Пример #3
0
 /**
  * New node is found.
  * @return bool
  */
 public function nodeOpened(MacroNode $node)
 {
     list($begin, $end, $attr) = $this->macros[$node->name];
     $node->isEmpty = !$end;
     if ($node->modifiers && (!$begin || is_string($begin) && strpos($begin, '%modify') === FALSE) && (!$end || is_string($end) && strpos($end, '%modify') === FALSE) && (!$attr || is_string($attr) && strpos($attr, '%modify') === FALSE)) {
         trigger_error('Modifiers are not allowed here.', E_USER_WARNING);
     }
     if ($attr && $node->prefix === $node::PREFIX_NONE) {
         $node->isEmpty = TRUE;
         $this->compiler->setContext(Latte\Compiler::CONTEXT_DOUBLE_QUOTED_ATTR);
         $res = $this->compile($node, $attr);
         if ($res === FALSE) {
             return FALSE;
         } elseif (!$node->attrCode) {
             $node->attrCode = "<?php {$res} ?>";
         }
         $this->compiler->setContext(NULL);
     } elseif ($begin) {
         $res = $this->compile($node, $begin);
         if ($res === FALSE || $node->isEmpty && $node->prefix) {
             return FALSE;
         } elseif (!$node->openingCode) {
             $node->openingCode = "<?php {$res} ?>";
         }
     } elseif (!$end) {
         return FALSE;
     }
 }
 /**
  * New node is found. Returns FALSE to reject.
  * @return bool
  */
 public function nodeOpened(MacroNode $node)
 {
     $node->isEmpty = FALSE;
     $this->compiler->setContext(Compiler::CONTEXT_DOUBLE_QUOTED_ATTR);
     $res1 = $this->compile($node, array($this, 'macroHref'));
     $this->compiler->setContext(NULL);
     if (!$node->attrCode) {
         $node->attrCode = "<?php {$res1} ?>";
     }
     $res2 = $this->compile($node, array('Foowie\\PermissionChecker\\Latte\\PermissionMacros', 'macroIfAllowedLink'));
     if (!$node->openingCode) {
         $node->openingCode = "<?php {$res2} ?>";
     }
     return $res1 !== false && $res2 !== false;
 }