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


PHP Twig_Loader_Filesystem::prependPath方法代码示例

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


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

示例1: array

 function __construct()
 {
     // This is how to call the template engine:
     // do_action('wunderground_render_template', $file_name, $data_array );
     add_action('wunderground_render_template', array(&$this, 'render'), 10, 2);
     // Set up Twig
     Twig_Autoloader::register();
     // This path should always be the last
     $base_path = trailingslashit(plugin_dir_path(Wunderground_Plugin::$file)) . 'templates';
     $this->loader = new Twig_Loader_Filesystem($base_path);
     // Tap in here to add additional template paths
     $additional_paths = apply_filters('wunderground_template_paths', array(trailingslashit(get_stylesheet_directory()) . 'wunderground'));
     foreach ($additional_paths as $path) {
         // If the directory exists
         if (is_dir($path)) {
             // Tell Twig to use it first
             $this->loader->prependPath($path);
         }
     }
     // You can force debug mode by adding `add_filter( 'wunderground_twig_debug' '__return_true' );`
     $debug = apply_filters('wunderground_twig_debug', current_user_can('manage_options') && isset($_GET['debug']));
     $this->twig = new Twig_Environment($this->loader, array('debug' => !empty($debug), 'auto_reload' => true));
     if (!empty($debug)) {
         $this->twig->addExtension(new Twig_Extension_Debug());
     }
 }
开发者ID:uwmadisoncals,项目名称:Cluster-Plugins,代码行数:26,代码来源:class-template.php

示例2: addDir

 /**
  * add a directory to template search dirs
  * @param string $directory
  * @param bool|true $primary
  * @return ITemplateEngine|void
  */
 public function addDir($directory, $primary = true)
 {
     if ($primary) {
         $this->twigLoader->prependPath($directory);
     } else {
         $this->twigLoader->addPath($directory);
     }
     $this->twigEnv->setLoader($this->twigLoader);
     return $this;
 }
开发者ID:aelix,项目名称:framework,代码行数:16,代码来源:TwigTemplateEngine.php

示例3: 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

示例4: 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

示例5: 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

示例6: prependTemplatesDirectory

 /**
  * Add a templates directory to the beginning of the list of existing ones known by the current Twig templates loader.
  * @param string $path Path to the templates directory to add.
  * @param string $namespace Namespace used to reference the directory inside the Twig templates loader.
  */
 public function prependTemplatesDirectory($path, $namespace = false)
 {
     if (StringUtils::emptyOrSpaces($namespace)) {
         $this->_loader->prependPath($path);
     } else {
         $this->_loader->prependPath($path, trim($namespace));
     }
 }
开发者ID:bgillet,项目名称:slim-twig,代码行数:13,代码来源:TwigView.php

示例7: register

 public function register(Container $app)
 {
     $app['twig.options'] = array('autoescape' => false, 'charset' => $app['app.charset'], 'debug' => $app['app.debug'], 'strict_variables' => $app['app.debug']);
     $app['twig.loader'] = function () use($app) {
         $theme = ucfirst($app->edition('theme'));
         $format = Toolkit::camelize($app->edition('format'), true);
         $loader = new \Twig_Loader_Filesystem($app['app.dir.themes']);
         // Base theme (common styles per edition type)
         // <easybook>/app/Resources/Themes/Base/<edition-type>/Templates/<template-name>.twig
         $baseThemeDir = sprintf('%s/Base/%s/Templates', $app['app.dir.themes'], $format);
         $loader->addPath($baseThemeDir);
         $loader->addPath($baseThemeDir, 'theme');
         $loader->addPath($baseThemeDir, 'theme_base');
         // Book theme (configured per edition in 'config.yml')
         // <easybook>/app/Resources/Themes/<theme>/<edition-type>/Templates/<template-name>.twig
         $bookThemeDir = sprintf('%s/%s/%s/Templates', $app['app.dir.themes'], $theme, $format);
         $loader->prependPath($bookThemeDir);
         $loader->prependPath($bookThemeDir, 'theme');
         $userTemplatePaths = array($app['publishing.dir.templates'], sprintf('%s/%s', $app['publishing.dir.templates'], strtolower($format)), sprintf('%s/%s', $app['publishing.dir.templates'], $app['publishing.edition']));
         foreach ($userTemplatePaths as $path) {
             if (file_exists($path)) {
                 $loader->prependPath($path);
             }
         }
         $defaultContentPaths = array(sprintf('%s/Base/%s/Contents', $app['app.dir.themes'], $format), sprintf('%s/%s/%s/Contents', $app['app.dir.themes'], $theme, $format));
         foreach ($defaultContentPaths as $path) {
             if (file_exists($path)) {
                 $loader->prependPath($path, 'content');
             }
         }
         return $loader;
     };
     $app['twig'] = function () use($app) {
         $twig = new \Twig_Environment($app['twig.loader'], $app['twig.options']);
         $twig->addExtension(new TwigCssExtension());
         $twig->addGlobal('app', $app);
         if (null !== ($bookConfig = $app['publishing.book.config'])) {
             $twig->addGlobal('book', $bookConfig['book']);
             $publishingEdition = $app['publishing.edition'];
             $editions = $app->book('editions');
             $twig->addGlobal('edition', $editions[$publishingEdition]);
         }
         return $twig;
     };
 }
开发者ID:jlaso,项目名称:easybook,代码行数:45,代码来源:TwigServiceProvider.php

示例8: configureLoader

 private function configureLoader(\Twig_Loader_Filesystem $loader, string $profile)
 {
     if (null === ($dancerDir = $this->config->get('dancer_directory'))) {
         return;
     }
     if (is_dir($dancerDir . '/templates')) {
         $loader->prependPath($dancerDir . '/templates');
     }
     $profile = str_replace(':', '_', $profile);
     if ('' !== $profile && is_dir($dancerDir . '/templates/' . $profile)) {
         $loader->addPath($dancerDir . '/templates/' . $profile);
     }
 }
开发者ID:rollerworks,项目名称:SkeletonDancer,代码行数:13,代码来源:TwigTemplating.php

示例9: createTemplateLoader

 public function createTemplateLoader($templatePath, $themePath = null)
 {
     $settings = $this->application->settings;
     if (array_key_exists('template_loader', $settings)) {
         return $settings['template_loader'];
     }
     $args = [];
     $fileLoader = new \Twig_Loader_Filesystem($templatePath);
     if ($themePath) {
         if (isset($this->theme)) {
             $fileLoader->prependPath($themePath . DS . $this->theme . DS . 'templates' . DS);
         }
     }
     $templates = $this->application->templates;
     if ($templates) {
         foreach ($templates as $name => $templatePath) {
             $fileLoader->addPath($templatePath, $name);
         }
     }
     $loaders = [$fileLoader];
     $loader = new \Twig_Loader_Chain($loaders);
     $options = [];
     if (array_key_exists('template_options', $settings)) {
         $options = $settings['template_options'];
     }
     $twig = new \Twig_Environment($loader, $options);
     foreach ($this->ui['modules'] as $uiModule) {
         $twig->addExtension(new $uiModule($this));
     }
     return $twig;
 }
开发者ID:radiumdigital,项目名称:caramel,代码行数:31,代码来源:RequestHandler.php

示例10: _initTwig

 private function _initTwig()
 {
     require_once BASE_FOLDER . '/lib/Twig/Autoloader.php';
     Twig_Autoloader::register();
     // file loader
     $loader = new Twig_Loader_Filesystem(TEMPLATES_FOLDER . '/' . TEMPLATE_SUBDIR_DEFAULT);
     $skinSubDir = $this->_skin->getTemplatesSubDirectory();
     if (strlen($skinSubDir) && $skinSubDir != TEMPLATE_SUBDIR_DEFAULT) {
         $loader->prependPath(TEMPLATES_FOLDER . '/' . $skinSubDir);
     }
     // environment config
     $twigConfig = array('cache' => CACHE_FOLDER);
     if (DEBUG) {
         $twigConfig['auto_reload'] = TRUE;
         $twigConfig['strict_variables'] = TRUE;
     }
     // init
     $this->_environment = new Twig_Environment($loader, $twigConfig);
 }
开发者ID:astroChasqui,项目名称:open-websoccer,代码行数:19,代码来源:TemplateEngine.class.php


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