Exemplo n.º 1
0
 /**
  * Save theme in storage
  *
  * @param \Ikantam\Theme\Theme $theme
  * @param \Ikantam\Theme\Layout $layout
  * @param string $templateName
  * @param string $html
  * @throws \Ikantam\Theme\Exception
  * @return mixed
  */
 public function save(Theme $theme, Layout $layout, $templateName, $html)
 {
     $themeName = $theme->getName();
     $themeModel = $this->createThemeModel();
     $themeModel->get_by_name($themeName);
     if (!$themeModel->exists()) {
         $themeModel->name = $themeName;
         $themeModel->date_installed = time();
         $themeModel->config_data = $this->valuesHandler->input('array', $theme->getConfig()->toArray());
         $themeModel->save();
     }
     $layoutModel = $this->createLayoutModel();
     $layoutFilter = $layoutModel->getFilter();
     $layoutFilter->name('=', $layout->getName())->theme_id('=', $themeModel->id)->apply(1);
     if (!$layoutModel->exists()) {
         $layoutModel->name = $layout->getName();
         $layoutModel->theme_id = $themeModel->id;
         $layoutModel->save();
     }
     $templateModel = $this->createTemplateModel();
     $templateFilter = $templateModel->getFilter();
     $templateFilter->layout_id('=', $layoutModel->id)->name('=', $templateName)->apply(1);
     if ($templateModel->exists()) {
         throw new Exception("Template {$templateName} for layout {$layout->getName()} already installed");
     }
     $templateModel->layout_id = $layoutModel->id;
     $templateModel->name = $templateName;
     $templateModel->html = $html;
     $templateModel->save();
     if ($templateModel->exists()) {
         $this->tagTemplate($templateModel);
     }
 }
Exemplo n.º 2
0
 /**
  * Uninstall theme
  * @param Theme $theme
  * @return void
  */
 public function uninstall(Theme $theme)
 {
     $this->storage->delete($theme->getName());
 }