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


PHP Twig_Environment::enableDebug方法代码示例

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


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

示例1: __construct

 /**
  * Twig adapter constructor.
  *
  * @param AbstractRenderer $renderer
  */
 public function __construct(AbstractRenderer $renderer, array $config = [])
 {
     parent::__construct($renderer, $config);
     $this->loader = new TwigLoaderFilesystem([]);
     $application = $this->renderer->getApplication();
     $this->twig = new \Twig_Environment($this->loader, $config);
     if ($application->isDebugMode() || isset($config['debug']) && true === $config['debug']) {
         $this->twig->enableDebug();
         $this->twig->addExtension(new \Twig_Extension_Debug());
     } elseif ($application->isClientSAPI()) {
         $this->twig->enableAutoReload();
         $this->setTwigCache($application->getCacheDir() . DIRECTORY_SEPARATOR . 'twig');
     }
 }
开发者ID:mickaelsteinberg,项目名称:BackBee,代码行数:19,代码来源:Twig.php

示例2: __construct

 /**
  * Twig adapter constructor.
  *
  * @param AbstractRenderer $renderer
  */
 public function __construct(AbstractRenderer $renderer, array $config = [])
 {
     parent::__construct($renderer, $config);
     $this->loader = new TwigLoaderFilesystem([]);
     $this->twig = new \Twig_Environment($this->loader, $config);
     $app = $this->renderer->getApplication();
     if ($app->isDebugMode() || isset($config['debug']) && true === $config['debug']) {
         $this->twig->enableDebug();
         $this->twig->addExtension(new \Twig_Extension_Debug());
     }
     if (isset($config['enable_autoreload']) && true === $config['enable_autoreload']) {
         $this->twig->enableAutoReload();
     }
     if (isset($config['enable_cache']) && true === $config['enable_cache']) {
         $cacheDir = isset($config['cache_dir']) && is_string($config['cache_dir']) ? $config['cache_dir'] : $app->getCacheDir() . DIRECTORY_SEPARATOR . 'twig';
         $this->setTwigCache($cacheDir);
     }
 }
开发者ID:vincentaubert,项目名称:BackBee,代码行数:23,代码来源:Twig.php

示例3: testOutput

 public function testOutput()
 {
     $this->fieldDescription->expects($this->any())->method('getTemplate')->will($this->returnValue('SonataAdminBundle:CRUD:base_list_field.html.twig'));
     $this->fieldDescription->expects($this->any())->method('getFieldName')->will($this->returnValue('fd_name'));
     $this->environment->disableDebug();
     $parameters = array('admin' => $this->admin, 'value' => 'foo', 'field_description' => $this->fieldDescription, 'object' => $this->object);
     $template = $this->environment->loadTemplate('SonataAdminBundle:CRUD:base_list_field.html.twig');
     $this->assertSame('<td class="sonata-ba-list-field sonata-ba-list-field-" objectId="12345"> foo </td>', trim(preg_replace('/\\s+/', ' ', $this->twigExtension->output($this->fieldDescription, $template, $parameters))));
     $this->environment->enableDebug();
     $this->assertSame('<!-- START fieldName: fd_name template: SonataAdminBundle:CRUD:base_list_field.html.twig compiled template: SonataAdminBundle:CRUD:base_list_field.html.twig --> <td class="sonata-ba-list-field sonata-ba-list-field-" objectId="12345"> foo </td> <!-- END - fieldName: fd_name -->', trim(preg_replace('/\\s+/', ' ', $this->twigExtension->output($this->fieldDescription, $template, $parameters))));
 }
开发者ID:clavier-souris,项目名称:SonataAdminBundle,代码行数:11,代码来源:SonataAdminExtensionTest.php

示例4: createTwig

 /**
  * Creates a Twig rendering engine
  * @param type $viewRootFolder
  * @param type $cacheFolder
  * @param type $debug
  * @return \Twig_Environment
  */
 protected function createTwig($viewRootFolder, $cacheFolder, $debug)
 {
     $this->loader = new \Twig_Loader_Filesystem($viewRootFolder);
     $twig = new \Twig_Environment($this->loader);
     $twig->enableStrictVariables();
     if ($debug === true) {
         $twig->enableDebug();
     } else {
         $twig->disableDebug();
         $twig->setCache($cacheFolder);
     }
     return $twig;
 }
开发者ID:blendsdk,项目名称:blendengine,代码行数:20,代码来源:TwigEngine.php

示例5: __construct

 /**
  * @param array $values
  */
 public function __construct($values = array())
 {
     $defaults['twig.options'] = array();
     $defaults['twig.directories'] = array();
     $defaults['twig.loader'] = function ($meadow) {
         // this needs to be lazy or theme switchers and alike explode it
         $stylesheet_dir = get_stylesheet_directory();
         $template_dir = get_template_directory();
         $calculated_dirs = array($stylesheet_dir, $template_dir, plugin_dir_path(__DIR__) . 'twig');
         // enables explicit inheritance from parent theme in child
         if ($stylesheet_dir !== $template_dir) {
             $calculated_dirs[] = dirname($template_dir);
         }
         $directories = array_unique(array_merge($calculated_dirs, $meadow['twig.directories']));
         return new \Twig_Loader_Filesystem($directories);
     };
     $defaults['twig.undefined_function'] = array(__CLASS__, 'undefined_function');
     $defaults['twig.undefined_filter'] = array(__CLASS__, 'undefined_filter');
     $defaults['twig.environment'] = function ($meadow) {
         $environment = new \Twig_Environment($meadow['twig.loader'], $meadow['twig.options']);
         $meadow_extension = new Extension();
         $environment->addExtension($meadow_extension);
         $environment->registerUndefinedFunctionCallback($meadow['twig.undefined_function']);
         $environment->registerUndefinedFilterCallback($meadow['twig.undefined_filter']);
         if (defined('WP_DEBUG') && WP_DEBUG) {
             $debug_extension = new \Twig_Extension_Debug();
             $environment->addExtension($debug_extension);
             $environment->enableDebug();
         }
         return $environment;
     };
     $defaults['hierarchy'] = function () {
         return new Template_Hierarchy();
     };
     parent::__construct(array_merge($defaults, $values));
 }
开发者ID:rarst,项目名称:meadow,代码行数:39,代码来源:class-core.php

示例6: render

 public function render()
 {
     delete_transient($this->transient_notices);
     $loader = new \Twig_Loader_Filesystem($this->paths);
     $twig = new \Twig_Environment($loader);
     // Add the admin_url() function.
     $twig->addFunction('admin_url', new \Twig_SimpleFunction('admin_url', 'admin_url'));
     // Add titlecase filter.
     $titlecase_filter = new \Twig_SimpleFilter('titlecase', '\\WordPress\\Tabulate\\Text::titlecase');
     $twig->addFilter($titlecase_filter);
     // Add date and time filters.
     $date_filter = new \Twig_SimpleFilter('wp_date_format', '\\WordPress\\Tabulate\\Text::wp_date_format');
     $twig->addFilter($date_filter);
     $time_filter = new \Twig_SimpleFilter('wp_time_format', '\\WordPress\\Tabulate\\Text::wp_time_format');
     $twig->addFilter($time_filter);
     // Add strtolower filter.
     $strtolower_filter = new \Twig_SimpleFilter('strtolower', function ($str) {
         if (is_array($str)) {
             return array_map('strtolower', $str);
         } else {
             return strtolower($str);
         }
     });
     $twig->addFilter($strtolower_filter);
     // Enable debugging.
     if (WP_DEBUG) {
         $twig->enableDebug();
         $twig->addExtension(new \Twig_Extension_Debug());
     }
     // Render the template.
     $template = $twig->loadTemplate($this->templateName);
     return $template->render($this->data);
 }
开发者ID:kcdipesh,项目名称:tabulate,代码行数:33,代码来源:Template.php

示例7: array

$counter = array('vehicles' => 0, 'realestate' => 0, 'jobs' => 0);
//var_dump($template);
//die('ok up to here');
//test mailer
//echo send_email($generalConfig);
$alertHandler = new Alert();
$formatter = new Formatter();
foreach ($regions as $region => $values) {
    $loader = new Twig_Loader_Filesystem(TWIG_TEMPLATES . '/' . $region);
    // TODO:
    // For some reason cache is not invalidated with chages - check it out then enable
    //$twig = new Twig_Environment($loader,array('cache' => TWIG_TEMPLATES.'/cache'));
    /// ... in the meantime
    $twig = new Twig_Environment($loader);
    if (SET_DEBUG) {
        $twig->enableDebug();
    } else {
        $twig->disableDebug();
    }
    // ... load the template
    outputStatus('Load html template ...');
    $template = $twig->loadTemplate('send_recommended/send_all.html');
    outputStatus('Region ' . $region);
    foreach ($sections as $section => $secParams) {
        outputStatus('Traverse section ' . $section);
        $formatter_conf = array('section' => $section, 'region' => $region, 'months' => $values['months'], 'base_domain' => $values['base_domain']);
        // var_dump($formatter_conf);die;
        $spx_config = $region . '_sphinx_' . $section;
        $alertHandler->resetArrays();
        $liveDB = new DBAdapter2(array('host' => $conf->dbserver->host, 'username' => $conf->dbserver->username, 'password' => $conf->dbserver->password, 'schema' => $values['live_schema']));
        // First drop all alerts older than specified!
开发者ID:sergrin,项目名称:crawlers-il,代码行数:31,代码来源:alert_saved_searches.php

示例8: addExtensionsFromTemplateConfiguration

 /**
  * Tries to add any custom extensions that have been defined in the template or the transformation's configuration.
  *
  * This method will read the `twig-extension` parameter of the transformation (which inherits the template's
  * parameter set) and try to add those extensions to the environment.
  *
  * @param Transformation    $transformation
  * @param ProjectDescriptor $project
  * @param \Twig_Environment $twigEnvironment
  *
  * @throws \InvalidArgumentException if a twig-extension should be loaded but it could not be found.
  *
  * @return void
  */
 protected function addExtensionsFromTemplateConfiguration(Transformation $transformation, ProjectDescriptor $project, \Twig_Environment $twigEnvironment)
 {
     $isDebug = $transformation->getParameter('twig-debug') ? $transformation->getParameter('twig-debug')->getValue() : false;
     if ($isDebug == 'true') {
         $twigEnvironment->enableDebug();
         $twigEnvironment->enableAutoReload();
         $twigEnvironment->addExtension(new \Twig_Extension_Debug());
     }
     /** @var Template\Parameter $extension */
     foreach ($transformation->getParametersWithKey('twig-extension') as $extension) {
         $extensionValue = $extension->getValue();
         if (!class_exists($extensionValue)) {
             throw new \InvalidArgumentException('Unknown twig extension: ' . $extensionValue);
         }
         // to support 'normal' Twig extensions we check the interface to determine what instantiation to do.
         $implementsInterface = in_array('phpDocumentor\\Plugin\\Twig\\ExtensionInterface', class_implements($extensionValue));
         $twigEnvironment->addExtension($implementsInterface ? new $extensionValue($project, $transformation) : new $extensionValue());
     }
 }
开发者ID:xxlixin1993,项目名称:phpDocumentor2,代码行数:33,代码来源:Twig.php

示例9: render

 /**
  * Render the template and return the output.
  * @return string
  */
 public function render()
 {
     if (isset($_SESSION[$this->transientNotices])) {
         unset($_SESSION[$this->transientNotices]);
     }
     $twig = new \Twig_Environment($this->loader);
     // Add titlecase filter.
     $titlecase_filter = new \Twig_SimpleFilter('titlecase', '\\Tabulate\\Text::titlecase');
     $twig->addFilter($titlecase_filter);
     // Add strtolower filter.
     $strtolower_filter = new \Twig_SimpleFilter('strtolower', function ($str) {
         if (is_array($str)) {
             return array_map('strtolower', $str);
         } else {
             return strtolower($str);
         }
     });
     $twig->addFilter($strtolower_filter);
     // Enable debugging.
     if (Config::debug()) {
         $this->queries = DB\Database::getQueries();
         $twig->enableDebug();
         $twig->addExtension(new \Twig_Extension_Debug());
     }
     // Render the template.
     if (!empty($this->templateString)) {
         $template = $twig->createTemplate($this->templateString);
     } else {
         $template = $twig->loadTemplate($this->templateName);
     }
     return $template->render($this->data);
 }
开发者ID:tabulate,项目名称:tabulate3,代码行数:36,代码来源:Template.php


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