mirror of
https://github.com/bdnugget/magento2.git
synced 2026-11-07 17:27:36 +00:00
# Conflicts: # dev/tests/integration/testsuite/Magento/Customer/Controller/AddressTest.php # dev/tests/integration/testsuite/Magento/Customer/Controller/Adminhtml/IndexTest.php
75 lines
2.5 KiB
PHP
75 lines
2.5 KiB
PHP
<?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;
|
|
}
|
|
}
|