本文整理汇总了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));
}
示例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));
}
示例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'));
}
示例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);
}
});
}