public static function syncAll()
    {
        MailLayout::createLayouts();
        MailPartial::createPartials();

        $templates = MailManager::instance()->listRegisteredTemplates();
        $dbTemplates = self::lists('is_custom', 'code');
        $newTemplates = array_diff_key($templates, $dbTemplates);

        /*
         * Clean up non-customized templates
         */
        foreach ($dbTemplates as $code => $isCustom) {
            if ($isCustom) {
                continue;
            }

            if (!array_key_exists($code, $templates)) {
                self::whereCode($code)->delete();
            }
        }

        /*
         * Create new templates
         */
        foreach ($newTemplates as $code) {
            $sections = self::getTemplateSections($code);
            $layoutCode = array_get($sections, 'settings.layout', 'default');
            $description = array_get($sections, 'settings.description');

            $template = self::make();
            $template->code = $code;
            $template->description = $description;
            $template->is_custom = 0;
            $template->layout_id = MailLayout::getIdFromCode($layoutCode);
            $template->forceSave();
        }
    }
public static function syncAll()
    {
        MailLayout::createLayouts();
        MailPartial::createPartials();

        $templates = MailManager::instance()->listRegisteredTemplates();
        $dbTemplates = self::lists('is_custom', 'code');
        $newTemplates = array_diff_key($templates, $dbTemplates);

        /*
         * Clean up non-customized templates
         */
        foreach ($dbTemplates as $code => $isCustom) {
            if ($isCustom) {
                continue;
            }

            if (!array_key_exists($code, $templates)) {
                self::whereCode($code)->delete();
            }
        }

        /*
         * Create new templates
         */
        foreach ($newTemplates as $code) {
            $sections = self::getTemplateSections($code);
            $layoutCode = array_get($sections, 'settings.layout', 'default');
            $description = array_get($sections, 'settings.description');

            $template = self::make();
            $template->code = $code;
            $template->description = $description;
            $template->is_custom = 0;
            $template->layout_id = MailLayout::getIdFromCode($layoutCode);
            $template->forceSave();
        }
    }
public static function syncAll ( ) { MailLayout :: createLayouts ( ) ; MailPartial :: createPartials ( ) ; $ templates = MailManager :: instance ( ) -> listRegisteredTemplates ( ) ; $ dbTemplates = self :: lists ( 'is_custom' , 'code' ) ; $ newTemplates = array_diff_key ( $ templates , $ dbTemplates ) ; /*
         * Clean up non-customized templates
         */ foreach ( $ dbTemplates as $ code => $ isCustom ) { if ( $ isCustom ) { continue ; } if ( ! array_key_exists ( $ code , $ templates ) ) { self :: whereCode ( $ code ) -> delete ( ) ; } } /*
         * Create new templates
         */ foreach ( $ newTemplates as $ code ) { $ sections = self :: getTemplateSections ( $ code ) ; $ layoutCode = array_get ( $ sections , 'settings.layout' , 'default' ) ; $ description = array_get ( $ sections , 'settings.description' ) ; $ template = self :: make ( ) ; $ template -> code = $ code ; $ template -> description = $ description ; $ template -> is_custom = 0 ; $ template -> layout_id = MailLayout :: getIdFromCode ( $ layoutCode ) ; $ template -> forceSave ( ) ; } }
Syncronise all file templates to the database.
@return void
Syncronise all file templates to the database .