public function rename($newThemeName)
 {
     $result = $this->canRename($newThemeName);
     if ($result['message']) {
         return $result;
     }
     if (!is_dir($this->_themeDir)) {
         return array('errors' => 'Theme `' . $this->_themeName . '` doesn\'t exist');
     }
     ProviderLog::start('rename');
     $isActive = Designer::isActiveTheme($this->_themeName);
     $this->prepareCopyRename($newThemeName);
     Designer::deleteTheme($this->_themeName);
     Designer::deleteTheme($this->_previewThemeName);
     Designer::addTheme($newThemeName);
     if ($isActive) {
         // renamed theme was activated before
         Designer::setActiveThemeForShop($newThemeName);
     }
     ProviderLog::end('rename');
     return array('result' => 'done', 'log' => ProviderLog::getLog());
 }
 public static function setActiveThemeForShop($themeName)
 {
     $id_theme = Designer::getThemeId($themeName);
     if (!$id_theme) {
         $id_theme = Designer::addTheme($themeName);
     }
     $shop = Designer::getShop();
     if ($id_theme && $shop->id_theme != $id_theme) {
         $shop->id_theme = $id_theme;
         $shop->update();
     }
     return $id_theme;
 }