![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/vendor/magento/module-search/Controller/Adminhtml/Term/ |
<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ namespace Magento\Search\Controller\Adminhtml\Term; use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface; use Magento\Search\Controller\Adminhtml\Term as TermController; use Magento\Backend\App\Action\Context; use Magento\Framework\Registry; use Magento\Framework\Controller\ResultFactory; class Edit extends TermController implements HttpGetActionInterface { /** * Core registry * * @var \Magento\Framework\Registry */ protected $coreRegistry; /** * @param \Magento\Backend\App\Action\Context $context * @param \Magento\Framework\Registry $coreRegistry */ public function __construct( Context $context, Registry $coreRegistry ) { $this->coreRegistry = $coreRegistry; parent::__construct($context); } /** * @return \Magento\Framework\Controller\ResultInterface * @SuppressWarnings(PHPMD.NPathComplexity) */ public function execute() { $id = $this->getRequest()->getParam('id'); $model = $this->_objectManager->create(\Magento\Search\Model\Query::class); if ($id) { $model->load($id); if (!$model->getId()) { $this->messageManager->addErrorMessage(__('This search no longer exists.')); /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */ $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT); $resultRedirect->setPath('search/*'); return $resultRedirect; } } // set entered data if was error when we do save $data = $this->_objectManager->get(\Magento\Backend\Model\Session::class)->getPageData(true); if (!empty($data)) { $model->addData($data); } $this->coreRegistry->register('current_catalog_search', $model); $resultPage = $this->createPage(); $resultPage->getConfig()->getTitle()->prepend(__('Search Terms')); $resultPage->getConfig()->getTitle()->prepend($id ? $model->getQueryText() : __('New Search')); $resultPage->getLayout()->getBlock('adminhtml.search.term.edit') ->setData('action', $this->getUrl('search/term/save')); $resultPage->addBreadcrumb( $id ? __('Edit Search') : __('New Search'), $id ? __('Edit Search') : __('New Search') ); return $resultPage; } }