Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
EditStore.php
Go to the documentation of this file.
1 <?php
8 
9 use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
10 
11 class EditStore extends \Magento\Backend\Controller\Adminhtml\System\Store implements HttpGetActionInterface
12 {
18  public function execute()
19  {
20  if ($this->_getSession()->getPostData()) {
21  $this->_coreRegistry->register('store_post_data', $this->_getSession()->getPostData());
22  $this->_getSession()->unsPostData();
23  }
24  if (!$this->_coreRegistry->registry('store_type')) {
25  $this->_coreRegistry->register('store_type', 'store');
26  }
27  if (!$this->_coreRegistry->registry('store_action')) {
28  $this->_coreRegistry->register('store_action', 'edit');
29  }
30  switch ($this->_coreRegistry->registry('store_type')) {
31  case 'website':
32  $itemId = $this->getRequest()->getParam('website_id', null);
33  $model = $this->_objectManager->create(\Magento\Store\Model\Website::class);
34  $title = __("Web Site");
35  $notExists = __("The website does not exist.");
36  $codeBase = __('Before modifying the website code please make sure it is not used in index.php.');
37  break;
38  case 'group':
39  $itemId = $this->getRequest()->getParam('group_id', null);
40  $model = $this->_objectManager->create(\Magento\Store\Model\Group::class);
41  $title = __("Store");
42  $notExists = __("The store does not exist");
43  $codeBase = false;
44  break;
45  case 'store':
46  $itemId = $this->getRequest()->getParam('store_id', null);
47  $model = $this->_objectManager->create(\Magento\Store\Model\Store::class);
48  $title = __("Store View");
49  $notExists = __("Store view doesn't exist");
50  $codeBase = __('Before modifying the store view code please make sure it is not used in index.php.');
51  break;
52  default:
53  break;
54  }
55  if (null !== $itemId) {
56  $model->load($itemId);
57  }
58 
59  if ($model->getId() || $this->_coreRegistry->registry('store_action') == 'add') {
60  $this->_coreRegistry->register('store_data', $model);
61  if ($this->_coreRegistry->registry('store_action') == 'edit' && $codeBase && !$model->isReadOnly()) {
62  $this->messageManager->addNoticeMessage($codeBase);
63  }
64  $resultPage = $this->createPage();
65  if ($this->_coreRegistry->registry('store_action') == 'add') {
66  $resultPage->getConfig()->getTitle()->prepend((__('New ') . $title));
67  } else {
68  $resultPage->getConfig()->getTitle()->prepend($model->getName());
69  }
70  $resultPage->getConfig()->getTitle()->prepend(__('Stores'));
71  $resultPage->addContent($resultPage->getLayout()->createBlock(
72  \Magento\Backend\Block\System\Store\Edit::class
73  ));
74  return $resultPage;
75  } else {
76  $this->messageManager->addErrorMessage($notExists);
78  $resultRedirect = $this->resultRedirectFactory->create();
79  return $resultRedirect->setPath('adminhtml/*/');
80  }
81  }
82 }
$title
Definition: default.phtml:14
__()
Definition: __.php:13