From f6fc1a4bd5f0eb1c53e83d39c183afe344561229 Mon Sep 17 00:00:00 2001 From: Richard Bayet Date: Tue, 21 Apr 2026 16:02:04 +0200 Subject: [PATCH] [Core] Adding missing Search Relevance Config controller --- .../Search/Request/RelevanceConfig/State.php | 84 +++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 src/module-elasticsuite-core/Controller/Adminhtml/Search/Request/RelevanceConfig/State.php diff --git a/src/module-elasticsuite-core/Controller/Adminhtml/Search/Request/RelevanceConfig/State.php b/src/module-elasticsuite-core/Controller/Adminhtml/Search/Request/RelevanceConfig/State.php new file mode 100644 index 000000000..b09a68a54 --- /dev/null +++ b/src/module-elasticsuite-core/Controller/Adminhtml/Search/Request/RelevanceConfig/State.php @@ -0,0 +1,84 @@ + + * @copyright 2026 Smile + * @license Open Software License ("OSL") v. 3.0 + */ + +namespace Smile\ElasticsuiteCore\Controller\Adminhtml\Search\Request\RelevanceConfig; + +use Magento\Backend\App\Action\Context; +use Magento\Config\Controller\Adminhtml\System\ConfigSectionChecker; +use Magento\Config\Model\Config\Structure; +use Magento\Framework\App\Action\HttpGetActionInterface; +use Magento\Framework\App\Action\HttpPostActionInterface; +use Magento\Framework\Controller\Result\RawFactory; +use Smile\ElasticsuiteCore\Model\Search\Request\RelevanceConfig; + +/** + * Save current state of open tabs controller (inherited logic from System\Config) dummy controller. + * + * @category Smile + * @package Smile\ElasticsuiteCore + */ +class State extends AbstractScopeConfig implements HttpPostActionInterface, HttpGetActionInterface +{ + /** + * @var RawFactory + */ + protected $resultRawFactory; + + /** + * Constructor. + * + * @param Context $context Action context. + * @param Structure $configStructure Relevance configuration Structure. + * @param ConfigSectionChecker $sectionChecker Configuration Section Checker. + * @param RelevanceConfig $backendConfig Configuration model. + * @param RawFactory $resultRawFactory Raw result factory. + */ + public function __construct( + Context $context, + Structure $configStructure, + ConfigSectionChecker $sectionChecker, + RelevanceConfig $backendConfig, + RawFactory $resultRawFactory + ) { + parent::__construct($context, $configStructure, $sectionChecker, $backendConfig); + $this->resultRawFactory = $resultRawFactory; + } + + /** + * Pretend saving fieldset state through AJAX. + * + * @return \Magento\Framework\Controller\Result\Raw + */ + public function execute() + { + $resultRaw = $this->resultRawFactory->create(); + + if ($this->getRequest()->getParam('isAjax')) { + return $resultRaw->setContents('success'); + } + + return $resultRaw->setContents('failure'); + } + + /** + * Check if access is allowed. + * + * @SuppressWarnings(PHPMD.CamelCaseMethodName) + * + * @return bool + */ + protected function _isAllowed() + { + return $this->_authorization->isAllowed('Smile_ElasticsuiteCore::manage_relevance'); + } +}