本文整理汇总了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);
}
}
}
示例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'));
}
示例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;
}
示例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;
}
示例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)));
}
示例6: testEmptyConstructor
public function testEmptyConstructor()
{
$loader = new Twig_Loader_Filesystem();
$this->assertEquals(array(), $loader->getPaths());
}
示例7: getScriptPath
/**
* @return string
*/
public function getScriptPath()
{
return $this->loader->getPaths();
}
示例8: getScriptPath
/**
* @return string
*/
public function getScriptPath()
{
$paths = $this->loader->getPaths();
return reset($paths);
}
示例9: getPaths
/**
* Gets the paths of the rendering environment.
*
* @return mixed
*/
public function getPaths()
{
return $this->twigFileLoader->getPaths();
}
示例10: getScriptPath
/**
* @return string
*/
public function getScriptPath()
{
$this->script_path = $this->loader->getPaths();
return reset($this->script_path);
}