當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。