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


PHP Twig_Loader_Filesystem::setPaths方法代码示例

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


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

示例1: setTwigLoaderPaths

 /**
  * @see AbstractTheme::setTwigLoaderPaths()
  *
  * @param \Twig_Loader_Filesystem $loader
  */
 protected function setTwigLoaderPaths(\Twig_Loader_Filesystem $loader)
 {
     $gantry = static::gantry();
     /** @var UniformResourceLocator $locator */
     $locator = $gantry['locator'];
     $loader->setPaths($locator->findResources('gantry-engine://twig'));
     $loader->setPaths($locator->findResources('gantry-pages://'), 'pages');
     $loader->setPaths($locator->findResources('gantry-positions://'), 'positions');
     parent::setTwigLoaderPaths($loader);
 }
开发者ID:rastabrane,项目名称:gantry5,代码行数:15,代码来源:Theme.php

示例2: renderer

 public function renderer()
 {
     if (!$this->renderer) {
         $gantry = \Gantry\Framework\Gantry::instance();
         /** @var UniformResourceLocator $locator */
         $locator = $gantry['locator'];
         $loader = new \Twig_Loader_Filesystem($locator->findResources('gantry-engine://twig'));
         $loader->setPaths($locator->findResources('gantry-pages://'), 'pages');
         $loader->setPaths($locator->findResources('gantry-positions://'), 'positions');
         $params = array('cache' => $locator('gantry-cache://twig', true, true), 'debug' => true, 'auto_reload' => true, 'autoescape' => 'html');
         $twig = new \Twig_Environment($loader, $params);
         $this->add_to_twig($twig);
         $this->renderer = $twig;
     }
     return $this->renderer;
 }
开发者ID:Acidburn0zzz,项目名称:gantry5,代码行数:16,代码来源:Theme.php

示例3: getTwig

 protected function getTwig()
 {
     $options = ['cache' => false, 'strict_variables' => true];
     $loader = new \Twig_Loader_Filesystem();
     $loader->setPaths($this->skeletonDirs);
     return new \Twig_Environment($loader, $options);
 }
开发者ID:spress,项目名称:spress,代码行数:7,代码来源:Generator.php

示例4: renderFile

 /**
  * This renders a file based on the $file and sf_type
  *
  * @param string $file the fullpath to the template file
  * @return string
  */
 protected function renderFile($file)
 {
     if (sfConfig::get('sf_logging_enabled', false)) {
         $this->dispatcher->notify(new sfEvent($this, 'application.log', array(sprintf('Render "%s".', $file))));
     }
     $this->loader->setPaths((array) realpath(dirname($file)));
     return $this->twig->loadTemplate(basename($file))->render($this->getAttributeHolderVariables());
 }
开发者ID:red1,项目名称:sfTwigPlugin,代码行数:14,代码来源:sfTwigView.class.php

示例5: setTwigLoaderPaths

 /**
  * @see AbstractTheme::setTwigLoaderPaths()
  *
  * @param \Twig_Loader_Filesystem $loader
  */
 protected function setTwigLoaderPaths(\Twig_Loader_Filesystem $loader)
 {
     $gantry = static::gantry();
     /** @var UniformResourceLocator $locator */
     $locator = $gantry['locator'];
     $loader->setPaths($locator->findResources('gantry-admin://templates'));
     $loader->setPaths($locator->findResources('gantry-admin://templates'), 'gantry-admin');
 }
开发者ID:rastabrane,项目名称:gantry5,代码行数:13,代码来源:Theme.php

示例6: renderFile

 /**
  * This renders a file based on the $file and sf_type.
  *
  * @param string $file the fullpath to the template file
  *
  * @return string
  */
 protected function renderFile($file)
 {
     if (sfConfig::get('sf_logging_enabled', false)) {
         $this->dispatcher->notify(new sfEvent($this, 'application.log', array(sprintf('Render "%s"', $file))));
     }
     $this->loader->setPaths((array) realpath(dirname($file)));
     $event = $this->dispatcher->filter(new sfEvent($this, 'template.filter_parameters'), $this->attributeHolder->getAll());
     return $this->twig->loadTemplate(basename($file))->render($event->getReturnValue());
 }
开发者ID:pycmam,项目名称:sfTwigPlugin,代码行数:16,代码来源:sfTwigView.class.php

示例7: setTwigLoaderPaths

 /**
  * @see AbstractTheme::setTwigLoaderPaths()
  *
  * @param \Twig_Loader_Filesystem $loader
  */
 protected function setTwigLoaderPaths(\Twig_Loader_Filesystem $loader)
 {
     $gantry = static::gantry();
     /** @var UniformResourceLocator $locator */
     $locator = $gantry['locator'];
     $paths = $locator->mergeResources(['gantry-theme://templates', 'gantry-engine://templates']);
     // TODO: right now we are replacing all paths; we need to do better, but there are some issues with this call.
     $loader->setPaths($paths);
     parent::setTwigLoaderPaths($loader);
 }
开发者ID:Tanver186,项目名称:gantry5,代码行数:15,代码来源:Theme.php

示例8: setNamespaces

 public function setNamespaces(\Silex\Application $app)
 {
     $namespaces = $this->getNamespaces($app);
     $app['twig.loader.filesystem'] = $app->share(function ($app) use($namespaces) {
         $loader = new \Twig_Loader_Filesystem($app['twig.path']);
         foreach ($namespaces as $ns => $path) {
             $loader->setPaths($path, $ns);
         }
         return $loader;
     });
 }
开发者ID:radmen,项目名称:fatso-skeleton,代码行数:11,代码来源:TwigExtender.php

示例9: load_twig

function load_twig()
{
    global $twig, $config;
    require 'lib/Twig/Autoloader.php';
    Twig_Autoloader::register();
    Twig_Autoloader::autoload('Twig_Extensions_Node_Trans');
    Twig_Autoloader::autoload('Twig_Extensions_TokenParser_Trans');
    Twig_Autoloader::autoload('Twig_Extensions_Extension_I18n');
    Twig_Autoloader::autoload('Twig_Extensions_Extension_Tinyboard');
    $loader = new Twig_Loader_Filesystem($config['dir']['template']);
    $loader->setPaths($config['dir']['template']);
    $twig = new Twig_Environment($loader, array('autoescape' => false, 'cache' => is_writable('templates') && (!is_dir('templates/cache') || is_writable('templates/cache')) ? "{$config['dir']['template']}/cache" : false, 'debug' => $config['debug']));
    $twig->addExtension(new Twig_Extensions_Extension_Tinyboard());
    $twig->addExtension(new Twig_Extensions_Extension_I18n());
}
开发者ID:carriercomm,项目名称:Tinyboard,代码行数:15,代码来源:template.php

示例10: testPaths

 public function testPaths()
 {
     $basePath = dirname(__FILE__) . '/Fixtures';
     $loader = new Twig_Loader_Filesystem(array($basePath . '/normal', $basePath . '/normal_bis'));
     $loader->setPaths(array($basePath . '/named', $basePath . '/named_bis'), 'named');
     $loader->addPath($basePath . '/named_ter', 'named');
     $loader->addPath($basePath . '/normal_ter');
     $loader->prependPath($basePath . '/normal_final');
     $loader->prependPath($basePath . '/named_final', 'named');
     $this->assertEquals(array($basePath . '/normal_final', $basePath . '/normal', $basePath . '/normal_bis', $basePath . '/normal_ter'), $loader->getPaths());
     $this->assertEquals(array($basePath . '/named_final', $basePath . '/named', $basePath . '/named_bis', $basePath . '/named_ter'), $loader->getPaths('named'));
     $this->assertEquals("path (final)\n", $loader->getSource('index.html'));
     $this->assertEquals("path (final)\n", $loader->getSource('@__main__/index.html'));
     $this->assertEquals("named path (final)\n", $loader->getSource('@named/index.html'));
 }
开发者ID:joan16v,项目名称:symfony2_test,代码行数:15,代码来源:FilesystemTest.php

示例11: testPaths

 public function testPaths()
 {
     $basePath = __DIR__ . '/Fixtures';
     $loader = new Twig_Loader_Filesystem(array($basePath . '/normal', $basePath . '/normal_bis'));
     $loader->setPaths(array($basePath . '/named', $basePath . '/named_bis'), 'named');
     $loader->addPath($basePath . '/named_ter', 'named');
     $loader->addPath($basePath . '/normal_ter');
     $loader->prependPath($basePath . '/normal_final');
     $loader->prependPath($basePath . '/named/../named_quater', 'named');
     $loader->prependPath($basePath . '/named_final', 'named');
     $this->assertEquals(array($basePath . '/normal_final', $basePath . '/normal', $basePath . '/normal_bis', $basePath . '/normal_ter'), $loader->getPaths());
     $this->assertEquals(array($basePath . '/named_final', $basePath . '/named/../named_quater', $basePath . '/named', $basePath . '/named_bis', $basePath . '/named_ter'), $loader->getPaths('named'));
     $this->assertEquals(realpath($basePath . '/named_quater/named_absolute.html'), realpath($loader->getCacheKey('@named/named_absolute.html')));
     $this->assertEquals("path (final)\n", $loader->getSource('index.html'));
     $this->assertEquals("path (final)\n", $loader->getSource('@__main__/index.html'));
     $this->assertEquals("named path (final)\n", $loader->getSource('@named/index.html'));
 }
开发者ID:youprofit,项目名称:Twig,代码行数:17,代码来源:FilesystemTest.php

示例12: testPaths

 /**
  * @dataProvider getBasePaths
  */
 public function testPaths($basePath)
 {
     $loader = new Twig_Loader_Filesystem(array($basePath . '/normal', $basePath . '/normal_bis'));
     $loader->setPaths(array($basePath . '/named', $basePath . '/named_bis'), 'named');
     $loader->addPath($basePath . '/named_ter', 'named');
     $loader->addPath($basePath . '/normal_ter');
     $loader->prependPath($basePath . '/normal_final');
     $loader->prependPath($basePath . '/named/../named_quater', 'named');
     $loader->prependPath($basePath . '/named_final', 'named');
     $this->assertEquals(array($basePath . '/normal_final', $basePath . '/normal', $basePath . '/normal_bis', $basePath . '/normal_ter'), $loader->getPaths());
     $this->assertEquals(array($basePath . '/named_final', $basePath . '/named/../named_quater', $basePath . '/named', $basePath . '/named_bis', $basePath . '/named_ter'), $loader->getPaths('named'));
     // do not use realpath here as it would make the test unuseful
     $this->assertEquals(str_replace('\\', '/', $basePath . '/named_quater/named_absolute.html'), str_replace('\\', '/', $loader->getCacheKey('@named/named_absolute.html')));
     $this->assertEquals("path (final)\n", $loader->getSource('index.html'));
     $this->assertEquals("path (final)\n", $loader->getSource('@__main__/index.html'));
     $this->assertEquals("named path (final)\n", $loader->getSource('@named/index.html'));
 }
开发者ID:sharenjoy,项目名称:axes,代码行数:20,代码来源:FilesystemTest.php

示例13: setTemplatesPaths

 /**
  * Sets the paths where templates are stored.
  *
  * @param   string|array  $paths            A path or an array of paths where to look for templates.
  * @param   bool          $overrideBaseDir  If true a path can be outside themes base directory.
  *
  * @return  Twig
  *
  * @since   1.0
  */
 public function setTemplatesPaths($paths, $overrideBaseDir = false)
 {
     if (!is_array($paths)) {
         $paths = array($paths);
     }
     foreach ($paths as $path) {
         if ($overrideBaseDir) {
             $this->templatesPaths[] = $path;
         } else {
             $this->templatesPaths[] = $this->config['templates_base_dir'] . $path;
         }
     }
     // Reset the paths if needed.
     if (is_object($this->twigLoader)) {
         try {
             $this->twigLoader->setPaths($this->templatesPaths);
         } catch (\Twig_Error_Loader $e) {
             echo $e->getRawMessage();
         }
     }
     return $this;
 }
开发者ID:dextercowley,项目名称:jissues,代码行数:32,代码来源:Twig.php

示例14: setViewPaths

 public function setViewPaths(array $paths = array())
 {
     $this->loader->setPaths($paths);
 }
开发者ID:blendsdk,项目名称:blendengine,代码行数:4,代码来源:TwigEngine.php

示例15: selectTheme

 public function selectTheme($theme)
 {
     $this->themeName = $theme;
     $this->selectThemePath();
     $this->loader->setPaths($this->dir() . $this->themePath);
 }
开发者ID:tyurderi,项目名称:slim-mvc,代码行数:6,代码来源:View.php


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