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


PHP Twig_Loader_Filesystem::getPaths方法代碼示例

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


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

示例1: dump

 public function dump()
 {
     $finder = new Finder();
     $twigNamespaces = $this->loader->getNamespaces();
     foreach ($twigNamespaces as $ns) {
         if (count($this->loader->getPaths($ns)) > 0) {
             $iterator = $finder->files()->in($this->loader->getPaths($ns));
             foreach ($iterator as $file) {
                 /** @var SplFileInfo $file */
                 $resource = new TwigResource($this->loader, '@' . $ns . '/' . $file->getRelativePathname());
                 $this->lam->addResource($resource, 'twig');
             }
         }
     }
     foreach ($this->lam->getNames() as $name) {
         $asset = $this->lam->get($name);
         $formula = $this->lam->getFormula($name);
         $debug = isset($formula[2]['debug']) ? $formula[2]['debug'] : $this->lam->isDebug();
         $combine = isset($formula[2]['combine']) ? $formula[2]['combine'] : null;
         if (null !== $combine ? !$combine : $debug) {
             foreach ($asset as $leaf) {
                 $this->aw->writeAsset($leaf);
             }
         } else {
             $this->aw->writeAsset($asset);
         }
     }
 }
開發者ID:saxulum,項目名稱:saxulum-assetic-twig-provider,代碼行數:28,代碼來源:Dumper.php

示例2: 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:alexBLR,項目名稱:firmware,代碼行數:15,代碼來源:FilesystemTest.php

示例3: getPaths

 /**
  * Get the template directories
  *
  * @return TemplatePath[]
  */
 public function getPaths()
 {
     $paths = [];
     foreach ($this->twigLoader->getNamespaces() as $namespace) {
         $name = $namespace !== TwigFilesystem::MAIN_NAMESPACE ? $namespace : null;
         foreach ($this->twigLoader->getPaths($namespace) as $path) {
             $paths[] = new TemplatePath($path, $name);
         }
     }
     return $paths;
 }
開發者ID:weierophinney,項目名稱:zend-expressive-twigrenderer,代碼行數:16,代碼來源:TwigRenderer.php

示例4: getTemplatePathname

 /**
  * Get a fully qualified path to a given template.
  * @param string $file Filename of the template to find in referenced templates directories.
  * @param string $namespace Namespace of a specific set of templates directories.
  * @return string The full pathname to the template or 'false' if not found.
  */
 public function getTemplatePathname($file, $namespace = false)
 {
     $pathname = false;
     if ($this->_loader->exists($file)) {
         $paths = StringUtils::emptyOrSpaces($namespace) ? $this->_loader->getPaths() : $this->_loader->getPaths(trim($namespace));
         foreach ($paths as $path) {
             $tmp_pathname = rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . ltrim($file, DIRECTORY_SEPARATOR);
             if (file_exists($tmp_pathname)) {
                 $pathname = $tmp_pathname;
                 break;
             }
         }
     }
     return $pathname;
 }
開發者ID:bgillet,項目名稱:slim-twig,代碼行數:21,代碼來源:TwigView.php

示例5: findTemplate

 /**
  * Determine the path of a template based on its name
  *
  * @param \Twig_Loader_Filesystem $filesystem
  * @param string                  $name
  *
  * @return string
  *
  * @throws Twig_Error_Loader
  */
 public static function findTemplate(\Twig_Loader_Filesystem $filesystem, $name)
 {
     $name = self::normalizeName($name);
     self::validateName($name);
     list($namespace, $shortname) = self::parseName($name);
     $paths = $filesystem->getPaths($namespace);
     if (empty($paths)) {
         throw new Twig_Error_Loader(sprintf('There are no registered paths for namespace "%s".', $namespace));
     }
     foreach ($paths as $path) {
         if (is_file($path . '/' . $shortname)) {
             if (false !== ($realpath = realpath($path . '/' . $shortname))) {
                 return $realpath;
             }
             return $path . '/' . $shortname;
         }
     }
     throw new Twig_Error_Loader(sprintf('Unable to find template "%s" (looked into: %s).', $name, implode(', ', $paths)));
 }
開發者ID:jmversteeg,項目名稱:jvwp,代碼行數:29,代碼來源:TemplateUtils.php

示例6: testEmptyConstructor

 public function testEmptyConstructor()
 {
     $loader = new Twig_Loader_Filesystem();
     $this->assertEquals(array(), $loader->getPaths());
 }
開發者ID:sharenjoy,項目名稱:axes,代碼行數:5,代碼來源:FilesystemTest.php

示例7: getScriptPath

 /**
  * @return string
  */
 public function getScriptPath()
 {
     return $this->loader->getPaths();
 }
開發者ID:jsyzchen,項目名稱:chen-yaf,代碼行數:7,代碼來源:Adapter.php

示例8: getScriptPath

 /**
  * @return string
  */
 public function getScriptPath()
 {
     $paths = $this->loader->getPaths();
     return reset($paths);
 }
開發者ID:lovelock,項目名稱:yaf-twig-adapter,代碼行數:8,代碼來源:Twig.php

示例9: getPaths

 /**
  * Gets the paths of the rendering environment.
  *
  * @return mixed
  */
 public function getPaths()
 {
     return $this->twigFileLoader->getPaths();
 }
開發者ID:newup,項目名稱:core,代碼行數:9,代碼來源:TemplateRenderer.php

示例10: getScriptPath

 /**
  * @return string
  */
 public function getScriptPath()
 {
     $this->script_path = $this->loader->getPaths();
     return reset($this->script_path);
 }
開發者ID:dalinhuang,項目名稱:51mook,代碼行數:8,代碼來源:TwigAdapter.php


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