|
| 1 | +<?php |
| 2 | +/** |
| 3 | + * DISCLAIMER |
| 4 | + * |
| 5 | + * Do not edit or add to this file if you wish to upgrade Smile ElasticSuite to newer versions in the future. |
| 6 | + * |
| 7 | + * @category Smile |
| 8 | + * @package Smile\ElasticsuiteCore |
| 9 | + * @author Richard Bayet <richard.bayet@smile.fr> |
| 10 | + * @copyright 2026 Smile |
| 11 | + * @license Open Software License ("OSL") v. 3.0 |
| 12 | + */ |
| 13 | + |
| 14 | +namespace Smile\ElasticsuiteCore\Controller\Adminhtml\Search\Request\RelevanceConfig; |
| 15 | + |
| 16 | +use Magento\Backend\App\Action\Context; |
| 17 | +use Magento\Config\Controller\Adminhtml\System\ConfigSectionChecker; |
| 18 | +use Magento\Config\Model\Config\Structure; |
| 19 | +use Magento\Framework\App\Action\HttpGetActionInterface; |
| 20 | +use Magento\Framework\App\Action\HttpPostActionInterface; |
| 21 | +use Magento\Framework\Controller\Result\RawFactory; |
| 22 | +use Smile\ElasticsuiteCore\Model\Search\Request\RelevanceConfig; |
| 23 | + |
| 24 | +/** |
| 25 | + * Save current state of open tabs controller (inherited logic from System\Config) dummy controller. |
| 26 | + * |
| 27 | + * @category Smile |
| 28 | + * @package Smile\ElasticsuiteCore |
| 29 | + */ |
| 30 | +class State extends AbstractScopeConfig implements HttpPostActionInterface, HttpGetActionInterface |
| 31 | +{ |
| 32 | + /** |
| 33 | + * @var RawFactory |
| 34 | + */ |
| 35 | + protected $resultRawFactory; |
| 36 | + |
| 37 | + /** |
| 38 | + * Constructor. |
| 39 | + * |
| 40 | + * @param Context $context Action context. |
| 41 | + * @param Structure $configStructure Relevance configuration Structure. |
| 42 | + * @param ConfigSectionChecker $sectionChecker Configuration Section Checker. |
| 43 | + * @param RelevanceConfig $backendConfig Configuration model. |
| 44 | + * @param RawFactory $resultRawFactory Raw result factory. |
| 45 | + */ |
| 46 | + public function __construct( |
| 47 | + Context $context, |
| 48 | + Structure $configStructure, |
| 49 | + ConfigSectionChecker $sectionChecker, |
| 50 | + RelevanceConfig $backendConfig, |
| 51 | + RawFactory $resultRawFactory |
| 52 | + ) { |
| 53 | + parent::__construct($context, $configStructure, $sectionChecker, $backendConfig); |
| 54 | + $this->resultRawFactory = $resultRawFactory; |
| 55 | + } |
| 56 | + |
| 57 | + /** |
| 58 | + * Pretend saving fieldset state through AJAX. |
| 59 | + * |
| 60 | + * @return \Magento\Framework\Controller\Result\Raw |
| 61 | + */ |
| 62 | + public function execute() |
| 63 | + { |
| 64 | + $resultRaw = $this->resultRawFactory->create(); |
| 65 | + |
| 66 | + if ($this->getRequest()->getParam('isAjax')) { |
| 67 | + return $resultRaw->setContents('success'); |
| 68 | + } |
| 69 | + |
| 70 | + return $resultRaw->setContents('failure'); |
| 71 | + } |
| 72 | + |
| 73 | + /** |
| 74 | + * Check if access is allowed. |
| 75 | + * |
| 76 | + * @SuppressWarnings(PHPMD.CamelCaseMethodName) |
| 77 | + * |
| 78 | + * @return bool |
| 79 | + */ |
| 80 | + protected function _isAllowed() |
| 81 | + { |
| 82 | + return $this->_authorization->isAllowed('Smile_ElasticsuiteCore::manage_relevance'); |
| 83 | + } |
| 84 | +} |
0 commit comments