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


PHP Twig_Environment::isDebug方法代码示例

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


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

示例1: compress

 public function compress($html)
 {
     if (!$this->twig->isDebug() || $this->forceCompression) {
         return $this->parser->compress($html);
     }
     return $html;
 }
开发者ID:panvagenas,项目名称:html-compress-twig,代码行数:7,代码来源:Extension.php

示例2: configure

 /**
  * Loads the Twig instance and registers the autoloader.
  */
 public function configure()
 {
     parent::configure();
     $this->configuration = $this->context->getConfiguration();
     // template name
     $template = sfConfig::get('sf_template');
     $templateDir = sfConfig::get('sf_template_dir') . '/' . $template;
     if (!file_exists($templateDir)) {
         throw new sfException(__METHOD__ . ": Couldn't find template " . $template);
     }
     // decorator template path
     $layoutTemplateDir = $templateDir . '/global';
     if (is_readable($layoutTemplateDir . '/' . $this->getDecoratorTemplate())) {
         $this->setDecoratorDirectory($layoutTemplateDir);
     }
     // module template path
     $moduleTemplateDir = $templateDir . '/modules/' . $this->moduleName;
     if (is_readable($moduleTemplateDir . '/' . $this->getTemplate())) {
         $this->setDirectory($moduleTemplateDir);
     }
     // init twig engine
     // empty array becuase it changes based on the rendering context
     $this->loader = new Twig_Loader_Filesystem(array());
     $this->twig = new sfTwigEnvironment($this->loader, array('cache' => sfConfig::get('sf_template_cache_dir') . '/' . $template, 'debug' => sfConfig::get('sf_debug', false), 'sf_context' => $this->context));
     if ($this->twig->isDebug()) {
         $this->twig->setAutoReload(true);
     }
     $this->loadExtensions();
 }
开发者ID:pycmam,项目名称:sfTwigPlugin,代码行数:32,代码来源:sfTwigView.class.php

示例3: output

 public function output(FieldDescriptionInterface $fieldDescription, $content)
 {
     if ($this->environment->isDebug()) {
         return sprintf("\n<!-- START - fieldName: %s, template: %s -->\n%s\n<!-- END - fieldName: %s -->", $fieldDescription->getFieldName(), $fieldDescription->getTemplate(), $content, $fieldDescription->getFieldName());
     }
     return $content;
 }
开发者ID:renegare,项目名称:AdminBundle,代码行数:7,代码来源:SonataAdminExtension.php

示例4: initExtensions

 /**
  * Инициализируется расширения, необходимые для работы
  */
 private function initExtensions()
 {
     if ($this->engine->isDebug()) {
         $this->engine->addExtension(new \Twig_Extension_Debug());
     }
     $this->engine->addExtension(new BitrixExtension());
     $this->engine->addExtension(new CustomFunctionsExtension());
 }
开发者ID:maximaster,项目名称:tools.twig,代码行数:11,代码来源:TemplateEngine.php

示例5: configure

 /**
  * Loads the Twig instance and registers the autoloader.
  *
  * @return void
  */
 public function configure()
 {
     parent::configure();
     $this->configuration = $this->context->getConfiguration();
     //Empty array becuase it changes based on the rendering context
     $this->loader = new Twig_Loader_Filesystem(array());
     $this->twig = new Twig_Environment($this->loader, array('cache' => sfConfig::get('sf_template_cache_dir'), 'debug' => sfConfig::get('sf_debug', false)));
     if ($this->twig->isDebug()) {
         $this->twig->setCache(null);
         $this->twig->setAutoReload(true);
     }
     $this->loadExtensions();
 }
开发者ID:red1,项目名称:sfTwigPlugin,代码行数:18,代码来源:sfTwigView.class.php

示例6: configure

 /**
  * Loads the Twig instance and registers the autoloader.
  */
 public function configure()
 {
     parent::configure();
     $this->configuration = $this->context->getConfiguration();
     require_once sfConfig::get('sf_twig_lib_dir', dirname(__FILE__) . '/../lib/vendor/Twig/lib') . '/Twig/Autoloader.php';
     Twig_Autoloader::register();
     // empty array becuase it changes based on the rendering context
     $this->loader = new Twig_Loader_Filesystem(array());
     $this->twig = new sfTwigEnvironment($this->loader, array('cache' => sfConfig::get('sf_template_cache_dir'), 'debug' => sfConfig::get('sf_debug', false), 'sf_context' => $this->context));
     if ($this->twig->isDebug()) {
         $this->twig->enableAutoReload();
         $this->twig->setCache(null);
     }
     $this->loadExtensions();
 }
开发者ID:ryanhughes,项目名称:sfTwigPlugin,代码行数:18,代码来源:sfTwigView.class.php

示例7: dump

 /**
  * {@inheritdoc}
  */
 public function dump(\Twig_Environment $env, $context)
 {
     if (!$env->isDebug()) {
         return null;
     }
     if (func_num_args() === 2) {
         $vars = [];
         foreach ($context as $key => $value) {
             if (!$value instanceof \Twig_Template) {
                 $vars[$key] = $value;
             }
         }
         $vars = [$vars];
     } else {
         $vars = func_get_args();
         unset($vars[0], $vars[1]);
     }
     $output = fopen('php://memory', 'r+b');
     $prevOutput = $this->dumper->setOutput($output);
     foreach ($vars as $value) {
         $this->dumper->dump($this->cloner->cloneVar($value));
     }
     $this->dumper->setOutput($prevOutput);
     rewind($output);
     return stream_get_contents($output);
 }
开发者ID:d-m-,项目名称:bolt,代码行数:29,代码来源:DumpExtension.php

示例8: dump

 /**
  * {@inheritdoc}
  */
 public function dump(\Twig_Environment $env, $context)
 {
     // Return if 'debug' is `false` in Twig, or there's no logged on user _and_ `debug_show_loggedoff` in
     // config.yml is `false`.
     if (!$env->isDebug() || $this->users->getCurrentUser() === null && !$this->debugShowLoggedoff) {
         return null;
     }
     if (func_num_args() === 2) {
         $vars = [];
         foreach ($context as $key => $value) {
             if (!$value instanceof \Twig_Template) {
                 $vars[$key] = $value;
             }
         }
         $vars = [$vars];
     } else {
         $vars = func_get_args();
         unset($vars[0], $vars[1]);
     }
     $output = fopen('php://memory', 'r+b');
     $prevOutput = $this->dumper->setOutput($output);
     foreach ($vars as $value) {
         $this->dumper->dump($this->cloner->cloneVar($value));
     }
     $this->dumper->setOutput($prevOutput);
     rewind($output);
     return stream_get_contents($output);
 }
开发者ID:robbert-vdh,项目名称:bolt,代码行数:31,代码来源:DumpExtension.php

示例9: content

    public function content($key, $type, array $arguments = array(), $default='') {

        $debugmessage = '';

        if ($this->env->isDebug()) {
            $debugmessage .= "<!--debug IbrowsSimpleCMS\n";
            $debugmessage .= "type=$type \n";
            $debugmessage .= "key=$key \n";
            $debugmessage .= "default=$default \n";
            $debugmessage .= "arguments=" . print_r($arguments, true) . " \n";
            $debugmessage .= '-->';

            if ($default == '') {
                $default = "$key-$type";
            }
        }

        $obj = $this->manager->find($type, $key);
        if ($obj) {
            $out = $debugmessage . $obj->toHTML($this, $arguments);
        } else {
            $out = $default;
        }


        
        $grant = $this->handler->isGranted('ibrows_simple_cms_content_edit_key', array('key'=> $key,'type'=>$type ));
        //$grant = $this->handler->isGranted('ibrows_simple_cms_content');
        if(!$grant){
          return $out;
        }
        

        return $this->wrapOutputForEdit($out, $key, $type, $arguments, $default);
    }
开发者ID:JackJones,项目名称:IbrowsSimpleCMSBundle,代码行数:35,代码来源:TwigExtension.php

示例10: dump

 public function dump(\Twig_Environment $env, $context)
 {
     if (!$env->isDebug() || !$this->cloner) {
         return;
     }
     if (2 === func_num_args()) {
         $vars = array();
         foreach ($context as $key => $value) {
             if (!$value instanceof \Twig_Template) {
                 $vars[$key] = $value;
             }
         }
         $vars = array($vars);
     } else {
         $vars = func_get_args();
         unset($vars[0], $vars[1]);
     }
     $html = '';
     $dumper = new HtmlDumper(function ($line, $depth) use(&$html) {
         if (-1 !== $depth) {
             $html .= str_repeat('  ', $depth) . $line . "\n";
         }
     });
     foreach ($vars as $value) {
         $dumper->dump($this->cloner->cloneVar($value));
     }
     return $html;
 }
开发者ID:vomasmic,项目名称:symfony,代码行数:28,代码来源:DumpExtension.php

示例11: dump

 public function dump(\Twig_Environment $env, $context)
 {
     if (!$env->isDebug()) {
         return;
     }
     if (2 === func_num_args()) {
         $vars = array();
         foreach ($context as $key => $value) {
             if (!$value instanceof \Twig_Template) {
                 $vars[$key] = $value;
             }
         }
         $vars = array($vars);
     } else {
         $vars = func_get_args();
         unset($vars[0], $vars[1]);
     }
     $dump = fopen('php://memory', 'r+b');
     $dumper = new HtmlDumper($dump);
     foreach ($vars as $value) {
         $dumper->dump($this->cloner->cloneVar($value));
     }
     rewind($dump);
     return stream_get_contents($dump);
 }
开发者ID:hannesvdvreken,项目名称:TwigBridge,代码行数:25,代码来源:Dump.php

示例12: getInstance

 private static function getInstance()
 {
     if (self::$instance) {
         return self::$instance;
     }
     $loader = new BitrixLoader($_SERVER['DOCUMENT_ROOT']);
     $c = Configuration::getInstance();
     $config = $c->get('maximaster');
     $twigConfig = (array) $config['tools']['twig'];
     $defaultConfig = array('debug' => false, 'charset' => SITE_CHARSET, 'cache' => $_SERVER['DOCUMENT_ROOT'] . '/bitrix/cache/maximaster/tools.twig', 'auto_reload' => isset($_GET['clear_cache']) && strtoupper($_GET['clear_cache']) == 'Y', 'autoescape' => false);
     $twigOptions = array_merge($defaultConfig, $twigConfig);
     $twig = new \Twig_Environment($loader, $twigOptions);
     if ($twig->isDebug()) {
         $twig->addExtension(new \Twig_Extension_Debug());
     }
     $twig->addExtension(new BitrixExtension());
     $twig->addExtension(new CustomFunctionsExtension());
     $event = new Event('', 'onAfterTwigTemplateEngineInited', array($twig));
     $event->send();
     if ($event->getResults()) {
         foreach ($event->getResults() as $evenResult) {
             if ($evenResult->getType() == \Bitrix\Main\EventResult::SUCCESS) {
                 $twig = current($evenResult->getParameters());
             }
         }
     }
     return self::$instance = $twig;
 }
开发者ID:mlavrinenko,项目名称:tools.twig,代码行数:28,代码来源:TemplateEngine.php

示例13: output

 /**
  * @param FieldDescriptionInterface $fieldDescription
  * @param \Twig_Template            $template
  * @param array                     $parameters
  *
  * @return string
  */
 public function output(FieldDescriptionInterface $fieldDescription, \Twig_Template $template, array $parameters = array())
 {
     $content = $template->render($parameters);
     if ($this->environment->isDebug()) {
         return sprintf("\n<!-- START  \n  fieldName: %s\n  template: %s\n  compiled template: %s\n -->\n%s\n<!-- END - fieldName: %s -->", $fieldDescription->getFieldName(), $fieldDescription->getTemplate(), $template->getTemplateName(), $content, $fieldDescription->getFieldName());
     }
     return $content;
 }
开发者ID:LamaDelRay,项目名称:test_symf,代码行数:15,代码来源:SonataAdminExtension.php

示例14: refFunction

 /**
  * @param Twig_Environment $env
  * @param array $context
  * @return string
  */
 function refFunction(Twig_Environment $env, array $context)
 {
     if (!$env->isDebug()) {
         return '';
     }
     ob_start();
     r(2 === func_num_args() ? $context : array_slice(func_get_args(), 2));
     return ob_get_clean();
 }
开发者ID:rubenvincenten,项目名称:twig_php_ref,代码行数:14,代码来源:Ref.php

示例15: compile

 /**
  * Compiles the node to PHP.
  *
  * @param \Twig_Compiler A Twig_Compiler instance
  */
 public function compile(\Twig_Compiler $compiler)
 {
     $compiler->addDebugInfo($this);
     $location = $this->listener_directory . $this->getNode('expr')->getAttribute('name');
     foreach ($this->environment->get_phpbb_extensions() as $ext_namespace => $ext_path) {
         $ext_namespace = str_replace('/', '_', $ext_namespace);
         if ($this->environment->isDebug()) {
             // If debug mode is enabled, lets check for new/removed EVENT
             //  templates on page load rather than at compile. This is
             //  slower, but makes developing extensions easier (no need to
             //  purge the cache when a new event template file is added)
             $compiler->write("if (\$this->env->getLoader()->exists('@{$ext_namespace}/{$location}.html')) {\n")->indent();
         }
         if ($this->environment->isDebug() || $this->environment->getLoader()->exists('@' . $ext_namespace . '/' . $location . '.html')) {
             $compiler->write("\$previous_look_up_order = \$this->env->getNamespaceLookUpOrder();\n")->write("\$this->env->setNamespaceLookUpOrder(array('{$ext_namespace}', '__main__'));\n")->write("\$this->env->loadTemplate('@{$ext_namespace}/{$location}.html')->display(\$context);\n")->write("\$this->env->setNamespaceLookUpOrder(\$previous_look_up_order);\n");
         }
         if ($this->environment->isDebug()) {
             $compiler->outdent()->write("}\n\n");
         }
     }
 }
开发者ID:ZerGabriel,项目名称:phpbb,代码行数:26,代码来源:event.php


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