From 942a8c000ec4d57321fdada1ea0d4b8e3e228bad Mon Sep 17 00:00:00 2001 From: Samuel Georges Date: Mon, 24 Aug 2015 20:31:44 +1000 Subject: [PATCH] Add helper for listing file + db templates --- modules/system/models/MailTemplate.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/modules/system/models/MailTemplate.php b/modules/system/models/MailTemplate.php index 2195a24c8..bc708ce66 100644 --- a/modules/system/models/MailTemplate.php +++ b/modules/system/models/MailTemplate.php @@ -45,6 +45,23 @@ class MailTemplate extends Model protected static $registeredTemplates; + /** + * Returns an array of template codes and descriptions. + * @return array + */ + public static function listAllTemplates() + { + $fileTemplates = (array) self::make()->listRegisteredTemplates(); + $dbTemplates = (array) self::lists('description', 'code'); + $templates = $fileTemplates + $dbTemplates; + ksort($templates); + return $templates; + } + + /** + * Syncronise all file templates to the database. + * @return void + */ public static function syncAll() { $templates = self::make()->listRegisteredTemplates();