Example #1
0
 /**
  * Save new templates for theme.
  *
  * @param string $themeName
  *
  * @return Template
  */
 public static function saveTemplates($themeName)
 {
     $additionalPath = 'templates' . DIRECTORY_SEPARATOR . 'templates.xml';
     $templateSkeleton = Themes::getFilePath($additionalPath);
     $formatter = Formatter::make(File::get($templateSkeleton), Formatter::XML);
     $templates = $formatter->toArray();
     foreach ($templates['template'] as $template) {
         $identifier = str_slug($template['@attributes']['identifier']);
         $title = $template['@attributes']['title'];
         if (!Template::whereIdentifier($identifier)->whereTheme($themeName)->exists()) {
             self::saveNewTemplate($themeName, $template);
         }
     }
 }
Example #2
0
 protected function create($templateIdentifier, $name, $type, $shortcut, $description)
 {
     return Page::create(['name' => $name, 'type' => $type, 'shortcut' => $shortcut, 'description' => $description, 'template_id' => Template::whereIdentifier($templateIdentifier)->first()->id]);
 }