public static function getPath($template, $format, $custom='templates')
	{
		$file = $template . '.' . $format;
		$rootDir = System::getContainer()->getParameter('kernel.project_dir');

		// Check the theme folder first
		if (file_exists($rootDir . '/' . $custom . '/' . $file))
		{
			return $rootDir . '/' . $custom . '/' . $file;
		}

		// Then check the global templates directory (see #5547)
		if ($custom != 'templates')
		{
			if (file_exists($rootDir . '/templates/' . $file))
			{
				return $rootDir . '/templates/' . $file;
			}
		}

		return static::getDefaultPath($template, $format);
	}