core-bundle/src/Resources/contao/dca/tl_theme.php
protected function doGetTemplateFolders($path, $level=0)
	{
		$return = array();
		$rootDir = Contao\System::getContainer()->getParameter('kernel.project_dir');

		foreach (scan($rootDir . '/' . $path) as $file)
		{
			if (is_dir($rootDir . '/' . $path . '/' . $file))
			{
				$return[$path . '/' . $file] = str_repeat(' &nbsp; &nbsp; ', $level) . $file;
				$return = array_merge($return, $this->doGetTemplateFolders($path . '/' . $file, $level+1));
			}
		}

		return $return;
	}
protected function doGetTemplateFolders($path, $level=0)
	{
		$return = array();
		$rootDir = Contao\System::getContainer()->getParameter('kernel.project_dir');

		foreach (scan($rootDir . '/' . $path) as $file)
		{
			if (is_dir($rootDir . '/' . $path . '/' . $file))
			{
				$return[$path . '/' . $file] = str_repeat(' &nbsp; &nbsp; ', $level) . $file;
				$return = array_merge($return, $this->doGetTemplateFolders($path . '/' . $file, $level+1));
			}
		}

		return $return;
	}
Return all template folders as array

@param string  $path
@param integer $level

@return array