]> git.andy128k.dev Git - ipf.git/commitdiff
extract template dirs method
authorAndrey Kutejko <andy128k@gmail.com>
Sun, 4 Jan 2015 10:40:52 +0000 (12:40 +0200)
committerAndrey Kutejko <andy128k@gmail.com>
Sun, 4 Jan 2015 10:40:52 +0000 (12:40 +0200)
ipf/project_template.php

index ced4a7ca255a60fefc407c10298132bb5b54e52a..f7a82de0e1b1f3c36bdade2756d92008c3d0ca12 100644 (file)
@@ -18,16 +18,7 @@ final class IPF_Project_Template
         $e->cache = IPF::get('tmp');
         $e->debug = IPF::get('debug');
 
-        // folders
-        $projectTemplates = IPF::get('project_path') . '/templates';
-        if (is_dir($projectTemplates))
-            $e->folders[] = $projectTemplates;
-
-        foreach (IPF_Project::getInstance()->appList() as $app) {
-            $applicationTemplates = $app->getPath() . 'templates';
-            if (is_dir($applicationTemplates))
-                $e->folders[] = $applicationTemplates;
-        }
+        $e->folders = self::templateDirs();
 
         $e->tags['url'] = 'IPF_Project_Template_Tag_Url';
         $e->tags['params'] = 'IPF_Project_Template_Tag_Params';
@@ -40,6 +31,23 @@ final class IPF_Project_Template
         return $e;
     }
 
+    public static function templateDirs()
+    {
+        $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;
+        }
+
+        return $dirs;
+    }
+
     public static function context($params=array(), $request=null)
     {
         if ($request) {