src/View/ViewServiceProvider.php
/**
	 * Loads applicable extensions from the specified namespace and directory, returning an array of extension
	 * instances.
	 *
	 * @return \Twig_Extension[]
	 */
Loads applicable extensions from the specified namespace and directory, returning an array of extension
instances.


Loads applicable extensions from the specified namespace and directory returning an array of extension instances .
protected function fetchExtensionDirectory($namespace, $dir, $loader) {
		if (!file_exists($dir) || !is_dir($dir)) {
			return array();
		}
		$files = scandir($dir);
		$extensions = array();
		foreach ($files as $file) {
			$path = Path::join($dir, $file);
			$className = $namespace . '\\' . Path::basename($file, '.php');
			if ($file == '.' || $file == '..') {
				continue;
			}
			if (is_dir($file)) {
				$recursive = $this->fetchExtensionDirectory(($namespace . '\\' . $file), $path, $loader);
				foreach ($recursive as $extension) {
					$extensions[] = $extension;
				}
			}
			else {
				if (class_exists($className)) {
					$extension = new $className($loader);
					if ($extension instanceof \Twig_Extension) {
						$extensions[] = $extension;
					}
				}
			}
		}
		return $extensions;
	}
protected function fetchExtensionDirectory ( $ namespace , $ dir , $ loader ) { if ( ! file_exists ( $ dir ) || ! is_dir ( $ dir ) ) { return array ( ) ; } $ files = scandir ( $ dir ) ; $ extensions = array ( ) ; foreach ( $ files as $ file ) { $ path = Path :: join ( $ dir , $ file ) ; $ className = $ namespace . '\\' . Path :: basename ( $ file , '.php' ) ; if ( $ file == '.' || $ file == '..' ) { continue ; } if ( is_dir ( $ file ) ) { $ recursive = $ this -> fetchExtensionDirectory ( ( $ namespace . '\\' . $ file ) , $ path , $ loader ) ; foreach ( $ recursive as $ extension ) { $ extensions [ ] = $ extension ; } } else { if ( class_exists ( $ className ) ) { $ extension = new $ className ( $ loader ) ; if ( $ extension instanceof \ Twig_Extension ) { $ extensions [ ] = $ extension ; } } } } return $ extensions ; }
Loads applicable extensions from the specified namespace and directory, returning an array of extension
 instances.
Loads applicable extensions from the specified namespace and directory returning an array of extension instances .