*/
class Twig_Loader_Filesystem implements Twig_LoaderInterface, Twig_ExistsLoaderInterface
{
+ /** Identifier of the main namespace. */
+ const MAIN_NAMESPACE = '__main__';
+
protected $paths;
protected $cache;
*
* @return array The array of paths where to look for templates
*/
- public function getPaths($namespace = '__main__')
+ public function getPaths($namespace = self::MAIN_NAMESPACE)
{
return isset($this->paths[$namespace]) ? $this->paths[$namespace] : array();
}
/**
* Returns the path namespaces.
*
- * The "__main__" namespace is always defined.
+ * The main namespace is always defined.
*
* @return array The array of defined namespaces
*/
* @param string|array $paths A path or an array of paths where to look for templates
* @param string $namespace A path namespace
*/
- public function setPaths($paths, $namespace = '__main__')
+ public function setPaths($paths, $namespace = self::MAIN_NAMESPACE)
{
if (!is_array($paths)) {
$paths = array($paths);
*
* @throws Twig_Error_Loader
*/
- public function addPath($path, $namespace = '__main__')
+ public function addPath($path, $namespace = self::MAIN_NAMESPACE)
{
// invalidate the cache
$this->cache = array();
*
* @throws Twig_Error_Loader
*/
- public function prependPath($path, $namespace = '__main__')
+ public function prependPath($path, $namespace = self::MAIN_NAMESPACE)
{
// invalidate the cache
$this->cache = array();
$this->validateName($name);
- $namespace = '__main__';
+ $namespace = self::MAIN_NAMESPACE;
if (isset($name[0]) && '@' == $name[0]) {
if (false === $pos = strpos($name, '/')) {
throw new Twig_Error_Loader(sprintf('Malformed namespaced template name "%s" (expecting "@namespace/template_name").', $name));