/home/techb158/immovalet.com/platform/packages/theme/src/Commands
Edit: /home/techb158/immovalet.com/platform/packages/theme/src/Commands/ThemeRenameCommand.php (2581B)
files = $files;
$this->themeService = $themeService;
}
/**
* Execute the console command.
*
* @return mixed
* @throws \League\Flysystem\FileNotFoundException
* @throws FileNotFoundException
*/
public function handle()
{
$theme = $this->getTheme();
$newName = $this->argument('newName');
if ($theme == $newName) {
$this->error('Theme name are the same!');
return 1;
}
if ($this->files->isDirectory(theme_path($newName))) {
$this->error('Theme "' . $theme . '" is already exists.');
return 1;
}
$this->files->move(theme_path($theme), theme_path($newName));
$this->themeService->activate($newName);
$themeOptions = SettingModel::where('key', 'LIKE', 'theme-' . $theme . '-%')->get();
foreach ($themeOptions as $option) {
$option->key = str_replace('theme-' . $theme, 'theme-' . $newName, $option->key);
$option->save();
}
Widget::where('theme', $theme)->update(['theme' => $newName]);
$widgets = Widget::where('theme', 'LIKE', $theme . '-%')->get();
foreach ($widgets as $widget) {
$widget->theme = str_replace($theme, $newName, $widget->theme);
$widget->save();
}
$this->info('Theme "' . $theme . '" has been renamed to ' . $newName . '!');
return 0;
}
}