當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Library::parseTwigTemplates方法代碼示例

本文整理匯總了PHP中Bolt\Library::parseTwigTemplates方法的典型用法代碼示例。如果您正苦於以下問題:PHP Library::parseTwigTemplates方法的具體用法?PHP Library::parseTwigTemplates怎麽用?PHP Library::parseTwigTemplates使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Bolt\Library的用法示例。


在下文中一共展示了Library::parseTwigTemplates方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testTemplateParser

 public function testTemplateParser()
 {
     $app = $this->getApp();
     $loader = $app['twig.loader'];
     $app['twig']->render('error.twig', ['context' => ['class' => 'BoltResponse', 'message' => 'Clippy is bent out of shape', 'code' => '1555', 'trace' => []]]);
     $templates = Library::parseTwigTemplates($loader);
     $this->assertEquals(1, count($templates));
 }
開發者ID:atiarda,項目名稱:bolt,代碼行數:8,代碼來源:BoltLibraryTest.php

示例2: testTemplateParser

 public function testTemplateParser()
 {
     $app = $this->getApp();
     $loader = $app['twig.loader'];
     $template = $app['twig']->render('error.twig');
     $templates = Library::parseTwigTemplates($loader);
     $this->assertEquals(1, count($templates));
     // Test deprecated function for now
     $this->assertEquals($templates, Library::hackislyParseRegexTemplates($loader));
 }
開發者ID:aaleksu,項目名稱:bolt_cm,代碼行數:10,代碼來源:BoltLibraryTest.php

示例3: collect

 /**
  * Collect information from Twig.
  *
  * @param Request    $request   The Request Object
  * @param Response   $response  The Response Object
  * @param \Exception $exception The Exception
  */
 public function collect(Request $request, Response $response, \Exception $exception = null)
 {
     $filters = array();
     $tests = array();
     $extensions = array();
     $functions = array();
     foreach ($this->getTwig()->getExtensions() as $extensionName => $extension) {
         /** @var $extension \Twig_ExtensionInterface */
         $extensions[] = array('name' => $extensionName, 'class' => get_class($extension));
         foreach ($extension->getFilters() as $filterName => $filter) {
             if ($filter instanceof \Twig_FilterInterface) {
                 $call = $filter->compile();
                 if (is_array($call) && is_callable($call)) {
                     $call = 'Method ' . $call[1] . ' of an object ' . get_class($call[0]);
                 }
             } elseif ($filter instanceof \Twig_SimpleFilter) {
                 $call = $filter->getName();
             } else {
                 continue;
             }
             $filters[] = array('name' => $filterName, 'extension' => $extensionName, 'call' => $call);
         }
         foreach ($extension->getTests() as $testName => $test) {
             if ($test instanceof \Twig_TestInterface) {
                 $call = $test->compile();
             } elseif ($test instanceof \Twig_SimpleTest) {
                 $call = $test->getName();
             } else {
                 continue;
             }
             $tests[] = array('name' => $testName, 'extension' => $extensionName, 'call' => $call);
         }
         foreach ($extension->getFunctions() as $functionName => $function) {
             if ($function instanceof \Twig_FunctionInterface) {
                 $call = $function->compile();
             } elseif ($function instanceof \Twig_SimpleFunction) {
                 $call = $function->getName();
             } else {
                 continue;
             }
             $functions[] = array('name' => $functionName, 'extension' => $extensionName, 'call' => $call);
         }
     }
     $this->data = array('extensions' => $extensions, 'tests' => $tests, 'filters' => $filters, 'functions' => $functions, 'templates' => Lib::parseTwigTemplates($this->app['twig.loader']), 'templatechosen' => $this->getTrackedValue('templatechosen'), 'templateerror' => $this->getTrackedValue('templateerror'));
 }
開發者ID:aleksabp,項目名稱:bolt,代碼行數:52,代碼來源:TwigDataCollector.php

示例4: initProfiler

 /**
  * Set up the profilers for the toolbar.
  */
 public function initProfiler()
 {
     // On 'after' attach the debug-bar, if debug is enabled.
     if (!($this['debug'] && ($this['session']->has('user') || $this['config']->get('general/debug_show_loggedoff')))) {
         error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_USER_DEPRECATED);
         return;
     }
     // Set the error_reporting to the level specified in config.yml
     error_reporting($this['config']->get('general/debug_error_level'));
     // Register Whoops, to handle errors for logged in users only.
     if ($this['config']->get('general/debug_enable_whoops')) {
         $this->register(new WhoopsServiceProvider());
         // Add a special handler to deal with AJAX requests
         if ($this['config']->getWhichEnd() == 'async') {
             $this['whoops']->pushHandler(new JsonResponseHandler());
         }
     }
     // Register the Silex/Symfony web debug toolbar.
     $this->register(new Silex\Provider\WebProfilerServiceProvider(), array('profiler.cache_dir' => $this['resources']->getPath('cache') . '/profiler', 'profiler.mount_prefix' => '/_profiler'));
     // Register the toolbar item for our Database query log.
     $this->register(new Provider\DatabaseProfilerServiceProvider());
     // Register the toolbar item for our bolt nipple.
     $this->register(new Provider\BoltProfilerServiceProvider());
     // Register the toolbar item for the Twig toolbar item.
     $this->register(new Provider\TwigProfilerServiceProvider());
     $this['twig.loader.filesystem'] = $this->share($this->extend('twig.loader.filesystem', function (\Twig_Loader_Filesystem $filesystem, Application $app) {
         $filesystem->addPath($app['resources']->getPath('root') . '/vendor/symfony/web-profiler-bundle/Symfony/Bundle/WebProfilerBundle/Resources/views', 'WebProfiler');
         $filesystem->addPath($app['resources']->getPath('app') . '/view', 'BoltProfiler');
         return $filesystem;
     }));
     // PHP 5.3 does not allow 'use ($this)' in closures.
     $app = $this;
     $this->after(function () use($app) {
         foreach (Lib::parseTwigTemplates($app['twig.loader.filesystem']) as $template) {
             $app['twig.logger']->collectTemplateData($template);
         }
     });
 }
開發者ID:uwfsae,項目名稱:team-website,代碼行數:41,代碼來源:Application.php


注:本文中的Bolt\Library::parseTwigTemplates方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。