本文整理汇总了PHP中Twig_Loader_Filesystem::getNamespaces方法的典型用法代码示例。如果您正苦于以下问题:PHP Twig_Loader_Filesystem::getNamespaces方法的具体用法?PHP Twig_Loader_Filesystem::getNamespaces怎么用?PHP Twig_Loader_Filesystem::getNamespaces使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Twig_Loader_Filesystem
的用法示例。
在下文中一共展示了Twig_Loader_Filesystem::getNamespaces方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGetNamespaces
public function testGetNamespaces()
{
$loader = new Twig_Loader_Filesystem(sys_get_temp_dir());
$this->assertEquals(array(Twig_Loader_Filesystem::MAIN_NAMESPACE), $loader->getNamespaces());
$loader->addPath(sys_get_temp_dir(), 'named');
$this->assertEquals(array(Twig_Loader_Filesystem::MAIN_NAMESPACE, 'named'), $loader->getNamespaces());
}
示例2: testGetNamespaces
public function testGetNamespaces()
{
$loader = new Twig_Loader_Filesystem(sys_get_temp_dir());
$this->assertEquals(array('__main__'), $loader->getNamespaces());
$loader->addPath(sys_get_temp_dir(), 'named');
$this->assertEquals(array('__main__', 'named'), $loader->getNamespaces());
}
示例3: 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);
}
}
}
示例4: __construct
/**
* TwigFilesystemProvider constructor.
* @param \Twig_Loader_Filesystem $loader
* @param string $root_path
* @param string $namespace
*/
public function __construct(\Twig_Loader_Filesystem $loader, $root_path, $namespace)
{
$this->loader = $loader;
$this->namespace = $namespace;
if (!in_array($namespace, $loader->getNamespaces())) {
$loader->addPath($root_path, $namespace);
}
}
示例5: 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;
}
示例6: getTemplatesNamespaces
/**
* Get templates directories namespaces.
* @return array An array of namespaces used to reference templates directories.
*/
public function getTemplatesNamespaces()
{
return $this->_loader->getNamespaces();
}