storeManager = $storeManager; $this->cookieBuilder = $cookieBuilder; } /** * @return \Magento\Framework\Controller\ResultInterface */ public function execute() { $storeId = (int) $this->getRequest()->getParam('store', 0); $id = (int) $this->getRequest()->getParam('id'); $store = $this->storeManager->getStore($storeId); $this->storeManager->setCurrentStore($store->getCode()); $cookie = $this->cookieBuilder->build($this->getRequest()); if ($id && ! $cookie->getId()) { $this->messageManager->addErrorMessage(__('This cookie cookie no longer exists.')); /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */ $resultRedirect = $this->resultRedirectFactory->create(); return $resultRedirect->setPath('*/*/'); } /** @var \Magento\Backend\Model\View\Result\Page $resultPage */ $resultPage = $this->resultFactory->create(ResultFactory::TYPE_PAGE); $this->initBreadcrumbAndMenu($resultPage)->addBreadcrumb( $id ? __('Edit Cookie') : __('New Cookie'), $id ? __('Edit Cookie') : __('New Cookie') ); $title = $resultPage->getConfig()->getTitle(); $title->prepend(__('Cookie Category')); $title->prepend($cookie->getId() ? __('Edit Cookie "%1"', $cookie->getName()) : __('New Cookie')); return $resultPage; } }