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


PHP Application::cacheTwigPath方法代码示例

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


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

示例1: register

 /**
  * {@inheritdoc}
  */
 public function register(Application $app)
 {
     $app->register(new SilexTwigServiceProvider(), ['twig.path' => $app->templatesPath(), 'twig.options' => ['debug' => !$app->isProduction(), 'cache' => $app->config('cache.enabled') ? $app->cacheTwigPath() : false]]);
     /* @var Twig_Environment $twig */
     $twig = $app['twig'];
     $twig->addGlobal('current_page', function () use($app) {
         return $app['request']->getRequestUri();
     });
     $twig->addGlobal('cfp_open', strtotime('now') < strtotime($app->config('application.enddate') . ' 11:59 PM'));
     if (!$app->isProduction()) {
         $twig->addExtension(new Twig_Extension_Debug());
     }
     $twig->addFunction(new Twig_SimpleFunction('uploads', function ($path) {
         return '/uploads/' . $path;
     }));
     $twig->addFunction(new Twig_SimpleFunction('assets', function ($path) {
         return '/assets/' . $path;
     }));
     $twig->addGlobal('site', $app->config('application'));
     // Twig Markdown Extension
     $markdown = new Ciconia();
     $markdown->addExtension(new InlineStyleExtension());
     $markdown->addExtension(new WhiteSpaceExtension());
     $engine = new CiconiaEngine($markdown);
     $twig->addExtension(new MarkdownExtension($engine));
     $twig->addGlobal('talkHelper', new TalkHelper($app->config('talk.categories'), $app->config('talk.levels'), $app->config('talk.types')));
 }
开发者ID:cgrandval,项目名称:opencfp,代码行数:30,代码来源:TwigServiceProvider.php

示例2: register

 /**
  * {@inheritdoc}
  */
 public function register(Application $app)
 {
     $app->register(new SilexTwigServiceProvider(), ['twig.path' => $app->templatesPath(), 'twig.options' => ['debug' => !$app->isProduction(), 'cache' => $app->config('cache.enabled') ? $app->cacheTwigPath() : false]]);
     if (!$app->isProduction()) {
         $app['twig']->addExtension(new Twig_Extension_Debug());
     }
     $app['twig']->addFunction(new Twig_SimpleFunction('uploads', function ($path) {
         return '/uploads/' . $path;
     }));
     $app['twig']->addFunction(new Twig_SimpleFunction('assets', function ($path) {
         return '/assets/' . $path;
     }));
     $app['twig']->addGlobal('site', $app->config('application'));
     // Twig Markdown Extension
     $markdown = new Ciconia();
     $markdown->addExtension(new InlineStyleExtension());
     $markdown->addExtension(new WhiteSpaceExtension());
     $engine = new CiconiaEngine($markdown);
     $app['twig']->addExtension(new MarkdownExtension($engine));
 }
开发者ID:hilltool,项目名称:opencfp,代码行数:23,代码来源:TwigServiceProvider.php

示例3: register

 /**
  * {@inheritdoc}
  */
 public function register(Application $app)
 {
     $app->register(new SilexTwigServiceProvider(), ['twig.path' => $app->templatesPath(), 'twig.options' => ['debug' => !$app->isProduction(), 'cache' => $app->config('cache.enabled') ? $app->cacheTwigPath() : false]]);
     if ($app->isProduction()) {
         $app->error(function (\Exception $e, $code) use($app) {
             switch ($code) {
                 case 401:
                     $message = $app['twig']->render('error/401.twig');
                     break;
                 case 403:
                     $message = $app['twig']->render('error/403.twig');
                     break;
                 case 404:
                     $message = $app['twig']->render('error/404.twig');
                     break;
                 default:
                     $message = $app['twig']->render('error/500.twig');
             }
             return new Response($message, $code);
         });
     } else {
         $app['twig']->addExtension(new Twig_Extension_Debug());
     }
     $app['twig']->addFunction(new Twig_SimpleFunction('uploads', function ($path) {
         return '/uploads/' . $path;
     }));
     $app['twig']->addFunction(new Twig_SimpleFunction('assets', function ($path) {
         return '/assets/' . $path;
     }));
     $app['twig']->addGlobal('site', $app->config('application'));
     // Twig Markdown Extension
     $markdown = new Ciconia();
     $markdown->addExtension(new InlineStyleExtension());
     $markdown->addExtension(new WhiteSpaceExtension());
     $engine = new CiconiaEngine($markdown);
     $app['twig']->addExtension(new MarkdownExtension($engine));
 }
开发者ID:AaronMuslim,项目名称:opencfp,代码行数:40,代码来源:TwigServiceProvider.php


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