From: Andrey Kutejko Date: Sun, 7 Jul 2013 06:44:33 +0000 (+0300) Subject: app level templates X-Git-Url: https://git.andy128k.dev/?a=commitdiff_plain;h=03741bee6f453b73a0ecccb213d891263da52fcb;p=ipf-template.git app level templates --- diff --git a/ipf/template/environment.php b/ipf/template/environment.php index 7d3d79a..0ea8b8e 100644 --- a/ipf/template/environment.php +++ b/ipf/template/environment.php @@ -10,8 +10,21 @@ abstract class IPF_Template_Environment public static function getDefault() { - if (!self::$defaultEnvironment) - self::$defaultEnvironment = new IPF_Template_Environment_FileSystem(IPF::get('template_dirs'), IPF::get('tmp')); + if (!self::$defaultEnvironment) { + $dirs = array(); + + $projectTemplates = IPF::get('project_path') . '/templates'; + if (is_dir($projectTemplates)) + $dirs[] = $projectTemplates; + + foreach (IPF_Project::getInstance()->appList() as $app) { + $applicationTemplates = $app->getPath() . 'templates'; + if (is_dir($applicationTemplates)) + $dirs[] = $applicationTemplates; + } + + self::$defaultEnvironment = new IPF_Template_Environment_FileSystem($dirs, IPF::get('tmp')); + } return self::$defaultEnvironment; } }