* @copyright Since 2007 PrestaShop SA and Contributors * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\PrestaShop\Core\Domain\Theme\CommandHandler; use PrestaShop\PrestaShop\Core\Addon\Theme\ThemeManager; use PrestaShop\PrestaShop\Core\Domain\Theme\Command\DeleteThemeCommand; use PrestaShop\PrestaShop\Core\Domain\Theme\Exception\CannotDeleteThemeException; /** * Class DeleteThemeHandler */ final class DeleteThemeHandler implements DeleteThemeHandlerInterface { /** * @var ThemeManager */ private $themeManager; /** * @param ThemeManager $themeManager */ public function __construct(ThemeManager $themeManager) { $this->themeManager = $themeManager; } /** * @param DeleteThemeCommand $command */ public function handle(DeleteThemeCommand $command) { $plainThemeName = $command->getThemeName()->getValue(); if (!$this->themeManager->uninstall($plainThemeName)) { throw new CannotDeleteThemeException(sprintf('Theme "%s" is used and thus cannot be deleted.', $plainThemeName)); } } }