当前位置: 首页>>代码示例>>PHP>>正文


PHP Twig_Compiler::getFilename方法代码示例

本文整理汇总了PHP中Twig_Compiler::getFilename方法的典型用法代码示例。如果您正苦于以下问题:PHP Twig_Compiler::getFilename方法的具体用法?PHP Twig_Compiler::getFilename怎么用?PHP Twig_Compiler::getFilename使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Twig_Compiler的用法示例。


在下文中一共展示了Twig_Compiler::getFilename方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: compile

 public function compile(Twig_Compiler $compiler)
 {
     $name = $this->getAttribute('name');
     $testMap = $compiler->getEnvironment()->getTests();
     if (!isset($testMap[$name])) {
         $message = sprintf('The test "%s" does not exist', $name);
         if ($alternatives = $compiler->getEnvironment()->computeAlternatives($name, array_keys($compiler->getEnvironment()->getTests()))) {
             $message = sprintf('%s. Did you mean "%s"', $message, implode('", "', $alternatives));
         }
         throw new Twig_Error_Syntax($message, $this->getLine(), $compiler->getFilename());
     }
     $name = $this->getAttribute('name');
     $node = $this->getNode('node');
     $compiler->raw($testMap[$name]->compile() . '(')->subcompile($node);
     if (null !== $this->getNode('arguments')) {
         $compiler->raw(', ');
         $max = count($this->getNode('arguments')) - 1;
         foreach ($this->getNode('arguments') as $i => $arg) {
             $compiler->subcompile($arg);
             if ($i != $max) {
                 $compiler->raw(', ');
             }
         }
     }
     $compiler->raw(')');
 }
开发者ID:nsiskov,项目名称:tools.siskov,代码行数:26,代码来源:Test.php

示例2: compile

 /**
  * Compiles the node to PHP.
  *
  * @param Twig_Compiler $compiler A Twig_Compiler instance
  */
 public function compile(Twig_Compiler $compiler)
 {
     $compiler->addDebugInfo($this)->write('')->subcompile($this->getNode('var'))->raw(' = ');
     if ($this->getNode('expr') instanceof Twig_Node_Expression_Name && '_self' === $this->getNode('expr')->getAttribute('name')) {
         $compiler->raw('$this');
     } else {
         $compiler->raw('$this->loadTemplate(')->subcompile($this->getNode('expr'))->raw(', ')->repr($compiler->getFilename())->raw(', ')->repr($this->getLine())->raw(')');
     }
     $compiler->raw(";\n");
 }
开发者ID:ccq18,项目名称:EduSoho,代码行数:15,代码来源:Import.php

示例3: compile

 public function compile(Twig_Compiler $compiler)
 {
     $name = $this->getNode('filter')->getAttribute('value');
     if (false === ($filter = $compiler->getEnvironment()->getFilter($name))) {
         $message = sprintf('The filter "%s" does not exist', $name);
         if ($alternatives = $compiler->getEnvironment()->computeAlternatives($name, array_keys($compiler->getEnvironment()->getFilters()))) {
             $message = sprintf('%s. Did you mean "%s"', $message, implode('", "', $alternatives));
         }
         throw new Twig_Error_Syntax($message, $this->getLine(), $compiler->getFilename());
     }
     $this->compileFilter($compiler, $filter);
 }
开发者ID:nsiskov,项目名称:tools.siskov,代码行数:12,代码来源:Filter.php

示例4: compile

 public function compile(Twig_Compiler $compiler)
 {
     if ($compiler->getEnvironment()->isStrictVariables()) {
         $name = $this->getAttribute('name');
         $type = $this->getAttribute('type');
         $compiler->addDebugInfo($this);
         if (0 === strcasecmp($type, 'array')) {
             $compiler->write("if (false === is_array(\$context['{$name}'])) {\n");
         } else {
             $compiler->write("if (false === \$context['{$name}'] instanceof {$type}) {\n");
         }
         $compiler->indent()->write("throw new Twig_Error_Runtime('variable \\'{$name}\\' is expected to be of type {$type} but '.get_class(\$context['{$name}']).' was provided.', {$this->getLine()}, '{$compiler->getFilename()}');\n")->outdent()->write("}\n");
     }
 }
开发者ID:superdav42,项目名称:Twig,代码行数:14,代码来源:Type.php

示例5: compile

 public function compile(\Twig_Compiler $compiler)
 {
     $compiler->addDebugInfo($this);
     try {
         $template = $compiler->getFilename();
         if (Helper::hasBufferKey($template, $this->tag)) {
             $string = Helper::getBufferKey($template, $this->tag);
         } else {
             $string = "[{$this->tag}]";
             // display a placeholder
         }
     } catch (\Exception $e) {
         $string = "[{$this->tag}]";
         // display a placeholder
     }
     $compiler->raw("echo secure_string('{$string}');");
 }
开发者ID:siipis,项目名称:cms,代码行数:17,代码来源:StringNode.php

示例6: compileConstructor

 protected function compileConstructor(Twig_Compiler $compiler)
 {
     $compiler->write("public function __construct(Twig_Environment \$env)\n", "{\n")->indent()->subcompile($this->getNode('constructor_start'))->write("parent::__construct(\$env);\n\n");
     // parent
     if (null === ($parent = $this->getNode('parent'))) {
         $compiler->write("\$this->parent = false;\n\n");
     } elseif ($parent instanceof Twig_Node_Expression_Constant) {
         $compiler->addDebugInfo($parent)->write('$this->parent = $this->loadTemplate(')->subcompile($parent)->raw(', ')->repr($compiler->getFilename())->raw(', ')->repr($this->getNode('parent')->getLine())->raw(");\n");
     }
     $countTraits = count($this->getNode('traits'));
     if ($countTraits) {
         // traits
         foreach ($this->getNode('traits') as $i => $trait) {
             $node = $trait->getNode('template');
             $compiler->write(sprintf('$_trait_%s = $this->loadTemplate(', $i))->subcompile($node)->raw(', ')->repr($compiler->getFilename())->raw(', ')->repr($node->getLine())->raw(");\n");
             $compiler->addDebugInfo($trait->getNode('template'))->write(sprintf("if (!\$_trait_%s->isTraitable()) {\n", $i))->indent()->write("throw new Twig_Error_Runtime('Template \"'.")->subcompile($trait->getNode('template'))->raw(".'\" cannot be used as a trait.');\n")->outdent()->write("}\n")->write(sprintf("\$_trait_%s_blocks = \$_trait_%s->getBlocks();\n\n", $i, $i));
             foreach ($trait->getNode('targets') as $key => $value) {
                 $compiler->write(sprintf('if (!isset($_trait_%s_blocks[', $i))->string($key)->raw("])) {\n")->indent()->write("throw new Twig_Error_Runtime(sprintf('Block ")->string($key)->raw(' is not defined in trait ')->subcompile($trait->getNode('template'))->raw(".'));\n")->outdent()->write("}\n\n")->write(sprintf('$_trait_%s_blocks[', $i))->subcompile($value)->raw(sprintf('] = $_trait_%s_blocks[', $i))->string($key)->raw(sprintf(']; unset($_trait_%s_blocks[', $i))->string($key)->raw("]);\n\n");
             }
         }
         if ($countTraits > 1) {
             $compiler->write("\$this->traits = array_merge(\n")->indent();
             for ($i = 0; $i < $countTraits; ++$i) {
                 $compiler->write(sprintf('$_trait_%s_blocks' . ($i == $countTraits - 1 ? '' : ',') . "\n", $i));
             }
             $compiler->outdent()->write(");\n\n");
         } else {
             $compiler->write("\$this->traits = \$_trait_0_blocks;\n\n");
         }
         $compiler->write("\$this->blocks = array_merge(\n")->indent()->write("\$this->traits,\n")->write("array(\n");
     } else {
         $compiler->write("\$this->blocks = array(\n");
     }
     // blocks
     $compiler->indent();
     foreach ($this->getNode('blocks') as $name => $node) {
         $compiler->write(sprintf("'%s' => array(\$this, 'block_%s'),\n", $name, $name));
     }
     if ($countTraits) {
         $compiler->outdent()->write(")\n");
     }
     $compiler->outdent()->write(");\n")->outdent()->subcompile($this->getNode('constructor_end'))->write("}\n\n");
 }
开发者ID:freeztime,项目名称:ignitedcms-pro,代码行数:43,代码来源:Module.php

示例7: compile

 public function compile(Twig_Compiler $compiler)
 {
     $name = $this->getAttribute('name');
     if (false === ($function = $compiler->getEnvironment()->getFunction($name))) {
         $message = sprintf('The function "%s" does not exist', $name);
         if ($alternatives = $compiler->getEnvironment()->computeAlternatives($name, array_keys($compiler->getEnvironment()->getFunctions()))) {
             $message = sprintf('%s. Did you mean "%s"', $message, implode('", "', $alternatives));
         }
         throw new Twig_Error_Syntax($message, $this->getLine(), $compiler->getFilename());
     }
     $compiler->raw($function->compile() . '(');
     $first = true;
     if ($function->needsEnvironment()) {
         $compiler->raw('$this->env');
         $first = false;
     }
     if ($function->needsContext()) {
         if (!$first) {
             $compiler->raw(', ');
         }
         $compiler->raw('$context');
         $first = false;
     }
     foreach ($function->getArguments() as $argument) {
         if (!$first) {
             $compiler->raw(', ');
         }
         $compiler->string($argument);
         $first = false;
     }
     foreach ($this->getNode('arguments') as $node) {
         if (!$first) {
             $compiler->raw(', ');
         }
         $compiler->subcompile($node);
         $first = false;
     }
     $compiler->raw(')');
 }
开发者ID:nsiskov,项目名称:tools.siskov,代码行数:39,代码来源:Function.php

示例8: addGetTemplate

 protected function addGetTemplate(Twig_Compiler $compiler)
 {
     $compiler->write('$this->loadTemplate(')->subcompile($this->getNode('expr'))->raw(', ')->repr($compiler->getFilename())->raw(', ')->repr($this->getLine())->raw(')');
 }
开发者ID:ccq18,项目名称:EduSoho,代码行数:4,代码来源:Include.php

示例9: compileLoadTemplate

 protected function compileLoadTemplate(Twig_Compiler $compiler, $node, $var)
 {
     if ($node instanceof Twig_Node_Expression_Constant) {
         $compiler->write(sprintf("%s = \$this->loadTemplate(", $var))->subcompile($node)->raw(', ')->repr($compiler->getFilename())->raw(', ')->repr($node->getLine())->raw(");\n");
     } else {
         $compiler->write(sprintf("%s = ", $var))->subcompile($node)->raw(";\n")->write(sprintf("if (!%s", $var))->raw(" instanceof Twig_Template) {\n")->indent()->write(sprintf("%s = \$this->loadTemplate(%s")->raw(', ')->repr($compiler->getFilename())->raw(', ')->repr($node->getLine())->raw(");\n", $var, $var))->outdent()->write("}\n");
     }
 }
开发者ID:Newleatk,项目名称:ist,代码行数:8,代码来源:Module.php

示例10: compileLoadTemplate

 protected function compileLoadTemplate(Twig_Compiler $compiler, $node, $var)
 {
     if ($node instanceof Twig_Node_Expression_Constant) {
         $compiler->write(sprintf('%s = $this->loadTemplate(', $var))->subcompile($node)->raw(', ')->repr($compiler->getFilename())->raw(', ')->repr($node->getLine())->raw(");\n");
     } else {
         throw new LogicException('Trait templates can only be constant nodes');
     }
 }
开发者ID:Dren-x,项目名称:mobit,代码行数:8,代码来源:Module.php

示例11: addGetTemplate

 protected function addGetTemplate(Twig_Compiler $compiler)
 {
     $compiler->write("\$this->loadTemplate(")->string($this->getAttribute('filename'))->raw(', ')->repr($compiler->getFilename())->raw(', ')->repr($this->getLine())->raw(', ')->string($this->getAttribute('index'))->raw(")");
 }
开发者ID:TheTypoMaster,项目名称:SPHERE-Framework,代码行数:4,代码来源:Embed.php

示例12: compileGetParent

 protected function compileGetParent(Twig_Compiler $compiler)
 {
     if (null === ($parent = $this->getNode('parent'))) {
         return;
     }
     $compiler->write("protected function doGetParent(array \$context)\n", "{\n")->indent()->addDebugInfo($parent)->write('return ');
     if ($parent instanceof Twig_Node_Expression_Constant) {
         $compiler->subcompile($parent);
     } else {
         $compiler->raw('$this->loadTemplate(')->subcompile($parent)->raw(', ')->repr($compiler->getFilename())->raw(', ')->repr($this->getNode('parent')->getLine())->raw(')');
     }
     $compiler->raw(";\n")->outdent()->write("}\n\n");
 }
开发者ID:betes-curieuses-design,项目名称:ElieJosiePhotographie,代码行数:13,代码来源:Module.php


注:本文中的Twig_Compiler::getFilename方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。