當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。