![]() 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/mirasvit/module-core/src/Core/Plugin/Backend/ |
<?php /** * Mirasvit * * This source file is subject to the Mirasvit Software License, which is available at https://mirasvit.com/license/. * Do not edit or add to this file if you wish to upgrade the to newer versions in the future. * If you wish to customize this module for your needs. * Please refer to http://www.magentocommerce.com for more information. * * @category Mirasvit * @package mirasvit/module-core * @version 1.4.31 * @copyright Copyright (C) 2023 Mirasvit (https://mirasvit.com/) */ namespace Mirasvit\Core\Plugin\Backend; use Magento\Config\Model\Config\ScopeDefiner; use Magento\Config\Model\Config\Structure; use Mirasvit\Core\Block\Adminhtml\Config\SuggesterField; use Mirasvit\Core\Service\CompatibilityService; use Mirasvit\Core\Service\SuggesterService; /** * @see \Magento\Config\Model\Config\Structure::getElementByPathParts() */ class AddSuggesterBlockPlugin { private $scopeDefiner; private $suggesterService; public function __construct( ScopeDefiner $scopeDefiner, SuggesterService $suggesterService ) { $this->scopeDefiner = $scopeDefiner; $this->suggesterService = $suggesterService; } /** * @param Structure $subject * @param \Magento\Config\Model\Config\Structure\Element\Section $result * * @return Structure\Element\Section */ public function afterGetElementByPathParts(Structure $subject, $result) { if (CompatibilityService::isMarketplace()) { return $result; } //check if enabled $sectionData = $result->getData(); if (!isset($sectionData['tab']) || $sectionData['tab'] !== 'mirasvit') { return $result; } list($moduleName) = explode('::', $sectionData['resource']); if (!$moduleName) { return $result; } $suggestion = $this->suggesterService->getSuggestion($moduleName); if (!$suggestion) { return $result; } $sectionData['children']['suggester'] = [ 'id' => 'suggester', 'type' => 'text', 'sortOrder' => '100000', 'showInDefault' => '1', 'showInWebsite' => '0', 'showInStore' => '0', 'label' => $suggestion['label'], 'children' => [ 'label' => [ 'id' => 'label', 'label' => 'Status', 'type' => 'label', 'frontend_model' => SuggesterField::class, 'showInDefault' => '1', 'showInWebsite' => '0', 'showInStore' => '0', 'comment' => $suggestion['text'], '_elementType' => 'field', ], ], ]; $result->setData($sectionData, $this->scopeDefiner->getScope()); return $result; } }