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


PHP Twig_Compiler::addDebugInfo方法代码示例

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


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

示例1: compile

 public function compile(\Twig_Compiler $compiler)
 {
     if ($this->getNode('default')) {
         $compiler->addDebugInfo($this)->write('echo $this->env->getExtension(\'defer\')->has(')->string($this->getAttribute('name'))->raw(") ? ")->write('$this->env->getExtension(\'defer\')->flush(')->string($this->getAttribute('name'))->raw(") : ")->subcompile($this->getNode('default'))->raw(";\n");
     } else {
         $compiler->addDebugInfo($this)->write('echo $this->env->getExtension(\'defer\')->flush(')->string($this->getAttribute('name'))->raw(");\n");
     }
 }
开发者ID:wucdbm,项目名称:twig-defer-extension,代码行数:8,代码来源:DeferredNode.php

示例2: compile

 /**
  * Compiles the node to PHP.
  *
  * @param Twig_Compiler A Twig_Compiler instance
  */
 public function compile(Twig_Compiler $compiler)
 {
     $attributes = $this->getAttribute('holder_attributes');
     if ($attributes) {
         $compiler->addDebugInfo($this)->write('$this->env->getView()->placeholder(')->string($this->placeholder)->raw(')->set(')->subcompile($attributes)->raw(');');
     } else {
         $compiler->addDebugInfo($this)->write('echo $this->env->getView()->placeholder(')->string($this->placeholder)->raw(');');
     }
 }
开发者ID:niborb,项目名称:Ano_ZFTwig,代码行数:14,代码来源:HolderNode.php

示例3: compile

 public function compile(\Twig_Compiler $compiler)
 {
     if ($this->value instanceof \Twig_Node_Expression) {
         $compiler->addDebugInfo($this)->write('$this->env->getExtension(\'defer\')->defer(')->string($this->getAttribute('name'))->raw(', ')->subcompile($this->getNode('value'))->raw(");\n");
     } else {
         // This is very ugly, but I don't know how else to handle \Twig_Node that compiles into this: echo "constant expression";
         $compiler->write("\$deferred = function() use (\$context, \$blocks) {")->indent()->write("ob_start();\n")->write("try {\n")->indent()->subcompile($this->getNode('value'))->write("return ob_get_clean();")->outdent()->write("} catch (Exception \$e) {\n")->indent()->write("ob_end_clean();\n\n")->write("throw \$e;\n")->outdent()->write("} catch (Throwable \$e) {\n")->indent()->write("ob_end_clean();\n\n")->write("throw \$e;\n")->outdent()->write("}\n\n")->outdent()->write("};");
         $compiler->addDebugInfo($this)->write('$this->env->getExtension(\'defer\')->defer(')->string($this->getAttribute('name'))->raw(', ')->write("\$deferred()")->raw(");\n");
     }
 }
开发者ID:wucdbm,项目名称:twig-defer-extension,代码行数:10,代码来源:DeferNode.php

示例4: compile

 public function compile(\Twig_Compiler $compiler)
 {
     foreach ($this->getAttribute('above_dumps') as $aboveDump) {
         $compiler->subcompile($aboveDump);
     }
     $compiler->addDebugInfo($this)->write("ob_start();\n")->subcompile($this->getAttribute('below_dump'));
     $compiler->write("\$buffer = ob_get_clean();\n");
     // echo $this->env->getExtension('stamp')->dumpStamp('svg');
     $compiler->addDebugInfo($this)->write("echo \$this->env->getExtension('stamp')->dumpStamp(")->string($this->getAttribute('name'))->raw(");\n");
     $compiler->write("echo \$buffer;\n");
 }
开发者ID:blablacar,项目名称:twig-stamp,代码行数:11,代码来源:StampNode.php

示例5: compile

 public function compile(\Twig_Compiler $compiler)
 {
     // @codingStandardsIgnoreEnd
     $compiler->addDebugInfo($this);
     if ($this->assign) {
         $compiler->raw('$context[\'' . $this->getAttribute('variable') . '\'] = ');
         // @codingStandardsIgnoreStart
     } else {
         // @codingStandardsIgnoreEnd
         $compiler->raw('echo ');
     }
     $compiler->raw('$context[\'_view\']->cell(');
     $compiler->subcompile($this->getNode('name'));
     $data = $this->getNode('data');
     if ($data !== null) {
         $compiler->raw(',');
         $compiler->subcompile($data);
     }
     $options = $this->getNode('options');
     if ($data !== null) {
         $compiler->raw(',');
         $compiler->subcompile($options);
     }
     $compiler->raw(");\n");
 }
开发者ID:luisfredgs,项目名称:TwigView,代码行数:25,代码来源:Cell.php

示例6: compile

 /**
  * Compiles the node to PHP.
  *
  * @param Twig_Compiler A Twig_Compiler instance
  */
 public function compile(Twig_Compiler $compiler)
 {
     $compiler
         ->addDebugInfo($this)
         ->write(sprintf("\$this->displayBlock('%s', \$context, \$blocks);\n", $this->getAttribute('name')))
     ;
 }
开发者ID:nizsheanez,项目名称:PolymorphCMS,代码行数:12,代码来源:BlockReference.php

示例7: compile

 /**
  * Compiles the node to PHP.
  *
  * @param Twig_Compiler A Twig_Compiler instance
  */
 public function compile(Twig_Compiler $compiler)
 {
     $compiler->addDebugInfo($this);
     $template = $this->getNode('expr')->getAttribute('value');
     $value = 'Elements' . DS . $template . '.tpl';
     $this->getNode('expr')->setAttribute('value', $value);
     if ($this->getNode('expr') instanceof Twig_Node_Expression_Constant) {
         $compiler->write("\$this->env->loadTemplate(")->subcompile($this->getNode('expr'))->raw(")->display(");
     } else {
         $compiler->write("\$template = ")->subcompile($this->getNode('expr'))->raw(";\n")->write("if (!\$template")->raw(" instanceof Twig_Template) {\n")->indent()->write("\$template = \$this->env->loadTemplate(\$template);\n")->outdent()->write("}\n")->write('$template->display(');
     }
     if (false === $this->getAttribute('only')) {
         if (null === $this->getNode('variables')) {
             $compiler->raw('$context');
         } else {
             $compiler->raw('array_merge($context, ')->subcompile($this->getNode('variables'))->raw(')');
         }
     } else {
         if (null === $this->getNode('variables')) {
             $compiler->raw('array()');
         } else {
             $compiler->subcompile($this->getNode('variables'));
         }
     }
     $compiler->raw(");\n");
 }
开发者ID:visonforcoding,项目名称:TwigView,代码行数:31,代码来源:Twig_Node_Element.php

示例8: compile

    /**
     * Compiles the node to PHP.
     *
     * @param Twig_Compiler A Twig_Compiler instance
     */
    public function compile(Twig_Compiler $compiler)
    {
        $arguments = array();
        foreach ($this->getNode('arguments') as $argument) {
            $arguments[] = '$'.$argument->getAttribute('name').' = null';
        }

        $compiler
            ->addDebugInfo($this)
            ->write(sprintf("public function get%s(%s)\n", $this->getAttribute('name'), implode(', ', $arguments)), "{\n")
            ->indent()
            ->write("\$context = array_merge(\$this->env->getGlobals(), array(\n")
            ->indent()
        ;

        foreach ($this->getNode('arguments') as $argument) {
            $compiler
                ->write('')
                ->string($argument->getAttribute('name'))
                ->raw(' => $'.$argument->getAttribute('name'))
                ->raw(",\n")
            ;
        }

        $compiler
            ->outdent()
            ->write("));\n\n")
            ->write("ob_start();\n")
            ->subcompile($this->getNode('body'))
            ->raw("\n")
            ->write("return ob_get_clean();\n")
            ->outdent()
            ->write("}\n\n")
        ;
    }
开发者ID:nizsheanez,项目名称:PolymorphCMS,代码行数:40,代码来源:Macro.php

示例9: compile

 public function compile(Twig_Compiler $compiler)
 {
     $name = $this->getAttribute('name');
     $compiler->addDebugInfo($this);
     if ($this->getAttribute('is_defined_test')) {
         if ($this->isSpecial()) {
             $compiler->repr(true);
         } else {
             $compiler->raw('array_key_exists(')->repr($name)->raw(', $context)');
         }
     } elseif ($this->isSpecial()) {
         $compiler->raw($this->specialVars[$name]);
     } elseif ($this->getAttribute('always_defined')) {
         $compiler->raw('$context[')->string($name)->raw(']');
     } else {
         if ($this->getAttribute('ignore_strict_check') || !$compiler->getEnvironment()->isStrictVariables()) {
             $compiler->raw('(isset($context[')->string($name)->raw(']) ? $context[')->string($name)->raw('] : null)');
         } else {
             // When Twig will require PHP 7.0, the Template::notFound() method
             // will be removed and the code inlined like this:
             // (function () { throw new Exception(...); })();
             $compiler->raw('(isset($context[')->string($name)->raw(']) || array_key_exists(')->string($name)->raw(', $context) ? $context[')->string($name)->raw('] : $this->notFound(')->string($name)->raw(', ')->repr($this->lineno)->raw('))');
         }
     }
 }
开发者ID:rjagadishsingh,项目名称:Twig,代码行数:25,代码来源:Name.php

示例10: compile

 public function compile(\Twig_Compiler $compiler)
 {
     $compiler->addDebugInfo($this);
     $type = $this->getAttribute('type');
     $template = $type == \Wave\View\Tag\Register::TYPE_JS ? self::FORMAT_JS : self::FORMAT_CSS;
     $compiler->write('foreach($this->env->_wave_register["' . $type . '"] as $priority => $files):')->raw("\n\t")->write('foreach($files as $file => $extra):')->raw("\n\t")->write('$code = sprintf("' . $template . '", $file, $extra);')->raw("\n\t")->write('echo $code . "<!-- $priority -->\\n";')->raw("\n\t")->write('endforeach;')->raw("\n")->write('endforeach;')->raw("\n");
 }
开发者ID:wave-framework,项目名称:wave,代码行数:7,代码来源:Output.php

示例11: compile

 /**
  * {@inheritDoc}
  */
 public function compile(\Twig_Compiler $compiler)
 {
     $compiler->addDebugInfo($this);
     $this->compileAsset($compiler, $this->compressedAsset, $this->nameCompress);
     $this->compileDebug($compiler);
     $compiler->write('unset($context[')->repr($this->getAttribute('var_name'))->raw("]);\n");
 }
开发者ID:noglitchyo,项目名称:pim-community-dev,代码行数:10,代码来源:OroAsseticNode.php

示例12: compile

 public function compile(\Twig_Compiler $compiler)
 {
     $count = count($this->getNode('params'));
     if ($count == 1) {
         throw new \Twig_Error_Runtime('Content identifier is missing.');
     } else {
         if ($count > 2) {
             throw new \Twig_Error_Runtime('Too many arguments.');
         }
     }
     $compiler->addDebugInfo($this);
     for ($i = 0; $i < $count; $i++) {
         // argument is not an expression (such as, a \Twig_Node_Textbody)
         // we should trick with output buffering to get a valid argument to pass
         // to the functionToCall() function.
         if (!$this->getNode('params')->getNode($i) instanceof \Twig_Node_Expression) {
             $compiler->write('ob_start();')->raw(PHP_EOL);
             $compiler->subcompile($this->getNode('params')->getNode($i));
             $compiler->write('$_content[] = ob_get_clean();')->raw(PHP_EOL);
         } else {
             $compiler->write('$_content[] = ')->subcompile($this->getNode('params')->getNode($i))->raw(';')->raw(PHP_EOL);
         }
     }
     $rawText = $this->retriever->render($this->getNode('params')->getNode(1)->getAttribute('value'), $this->getNode('params')->getNode(0)->getAttribute('data'));
     $compiler->raw('echo "' . str_replace('"', '\\"', $rawText) . '";')->raw(PHP_EOL);
 }
开发者ID:phmlabs,项目名称:twigcontentbundle,代码行数:26,代码来源:ContentNode.php

示例13: compile

 /**
  * Compiles the node to PHP.
  *
  * @param Twig_Compiler A Twig_Compiler instance
  */
 public function compile(Twig_Compiler $compiler)
 {
     $compiler->addDebugInfo($this);
     if ($this->getAttribute('ignore_missing')) {
         $compiler->write("try {\n")->indent();
     }
     if ($this->getNode('expr') instanceof Twig_Node_Expression_Constant) {
         $compiler->write("\$this->env->loadTemplate(")->subcompile($this->getNode('expr'))->raw(")->display(");
     } else {
         $compiler->write("\$template = \$this->env->resolveTemplate(")->subcompile($this->getNode('expr'))->raw(");\n")->write('$template->display(');
     }
     if (false === $this->getAttribute('only')) {
         if (null === $this->getNode('variables')) {
             $compiler->raw('$context');
         } else {
             $compiler->raw('array_merge($context, ')->subcompile($this->getNode('variables'))->raw(')');
         }
     } else {
         if (null === $this->getNode('variables')) {
             $compiler->raw('array()');
         } else {
             $compiler->subcompile($this->getNode('variables'));
         }
     }
     $compiler->raw(");\n");
     if ($this->getAttribute('ignore_missing')) {
         $compiler->outdent()->write("} catch (Twig_Error_Loader \$e) {\n")->indent()->write("// ignore missing template\n")->outdent()->write("}\n\n");
     }
 }
开发者ID:3dw1np,项目名称:wf3,代码行数:34,代码来源:Include.php

示例14: compile

 /**
  * Compiles the node to PHP.
  *
  * @param Twig_Compiler A Twig_Compiler instance
  */
 public function compile(Twig_Compiler $compiler)
 {
     $compiler->addDebugInfo($this);
     list($msg, $vars) = $this->compileString($this->getNode('body'));
     if (null !== $this->getNode('plural')) {
         list($msg1, $vars1) = $this->compileString($this->getNode('plural'));
         $vars = array_merge($vars, $vars1);
     }
     $function = null === $this->getNode('plural') ? 'gettext' : 'ngettext';
     if ($vars) {
         $compiler->write('echo strtr(' . $function . '(')->subcompile($msg);
         if (null !== $this->getNode('plural')) {
             $compiler->raw(', ')->subcompile($msg1)->raw(', abs(')->subcompile($this->getNode('count'))->raw(')');
         }
         $compiler->raw('), array(');
         foreach ($vars as $var) {
             if ('count' === $var->getAttribute('name')) {
                 $compiler->string('%count%')->raw(' => abs(')->subcompile($this->getNode('count'))->raw('), ');
             } else {
                 $compiler->string('%' . $var->getAttribute('name') . '%')->raw(' => ')->subcompile($var)->raw(', ');
             }
         }
         $compiler->raw("));\n");
     } else {
         $compiler->write('echo ' . $function . '(')->subcompile($msg);
         if (null !== $this->getNode('plural')) {
             $compiler->raw(', ')->subcompile($msg1)->raw(', abs(')->subcompile($this->getNode('count'))->raw(')');
         }
         $compiler->raw(");\n");
     }
 }
开发者ID:nzzdev,项目名称:Twig-extensions,代码行数:36,代码来源:Trans.php

示例15: compile

 public function compile(Twig_Compiler $compiler)
 {
     $compiler->addDebugInfo($this)->write(sprintf('public function macro_%s(', $this->getAttribute('name')));
     $count = count($this->getNode('arguments'));
     $pos = 0;
     foreach ($this->getNode('arguments') as $name => $default) {
         $compiler->raw('$__' . $name . '__ = ')->subcompile($default);
         if (++$pos < $count) {
             $compiler->raw(', ');
         }
     }
     if (PHP_VERSION_ID >= 50600) {
         if ($count) {
             $compiler->raw(', ');
         }
         $compiler->raw('...$__varargs__');
     }
     $compiler->raw(")\n")->write("{\n")->indent();
     $compiler->write("\$context = \$this->env->mergeGlobals(array(\n")->indent();
     foreach ($this->getNode('arguments') as $name => $default) {
         $compiler->addIndentation()->string($name)->raw(' => $__' . $name . '__')->raw(",\n");
     }
     $compiler->addIndentation()->string(self::VARARGS_NAME)->raw(' => ');
     if (PHP_VERSION_ID >= 50600) {
         $compiler->raw("\$__varargs__,\n");
     } else {
         $compiler->raw('func_num_args() > ')->repr($count)->raw(' ? array_slice(func_get_args(), ')->repr($count)->raw(") : array(),\n");
     }
     $compiler->outdent()->write("));\n\n")->write("\$blocks = array();\n\n")->write("ob_start();\n")->write("try {\n")->indent()->subcompile($this->getNode('body'))->raw("\n")->write("return ('' === \$tmp = ob_get_contents()) ? '' : new Twig_Markup(\$tmp, \$this->env->getCharset());\n")->outdent()->write("} finally {\n")->indent()->write("ob_end_clean();\n")->outdent()->write("}\n")->outdent()->write("}\n\n");
 }
开发者ID:dunglas,项目名称:Twig,代码行数:30,代码来源:Macro.php


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