123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- <?php
- /**
- *
- * Copyright © Magento, Inc. All rights reserved.
- * See COPYING.txt for license details.
- */
- namespace Magento\Theme\Controller\Adminhtml\System\Design\Theme;
- use Magento\Framework\Controller\ResultFactory;
- /**
- * Class Delete
- * @deprecated 100.2.0
- */
- class Delete extends \Magento\Theme\Controller\Adminhtml\System\Design\Theme
- {
- /**
- * Delete action
- *
- * @return \Magento\Backend\Model\View\Result\Redirect
- */
- public function execute()
- {
- $themeId = $this->getRequest()->getParam('id');
- try {
- if ($themeId) {
- /** @var $theme \Magento\Framework\View\Design\ThemeInterface */
- $theme = $this->_objectManager->create(
- \Magento\Framework\View\Design\ThemeInterface::class
- )->load($themeId);
- if (!$theme->getId()) {
- throw new \InvalidArgumentException(sprintf('We cannot find a theme with id "%1".', $themeId));
- }
- if (!$theme->isVirtual()) {
- throw new \InvalidArgumentException(
- sprintf('Only virtual theme is possible to delete and theme "%s" isn\'t virtual', $themeId)
- );
- }
- $theme->delete();
- $this->messageManager->addSuccess(__('You deleted the theme.'));
- }
- } catch (\Magento\Framework\Exception\LocalizedException $e) {
- $this->messageManager->addError($e->getMessage());
- } catch (\Exception $e) {
- $this->messageManager->addException($e, __('We cannot delete the theme.'));
- $this->_objectManager->get(\Psr\Log\LoggerInterface::class)->critical($e);
- }
- $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
- return $resultRedirect->setPath('adminhtml/*/');
- }
- }
|