|
| 1 | +<?php |
| 2 | +/** |
| 3 | + * Copyright © Magento, Inc. All rights reserved. |
| 4 | + * See COPYING.txt for license details. |
| 5 | + */ |
| 6 | +declare(strict_types=1); |
| 7 | + |
| 8 | +namespace Magento\Store\Ui\Component\Form\Field; |
| 9 | + |
| 10 | +use Magento\Framework\View\Element\UiComponent\ContextInterface; |
| 11 | +use Magento\Framework\View\Element\UiComponentFactory; |
| 12 | +use Magento\Store\Model\StoreManagerInterface as StoreManager; |
| 13 | +use Magento\Ui\Component\Form\Field; |
| 14 | + |
| 15 | +/** |
| 16 | + * Check to disable store view field |
| 17 | + * |
| 18 | + * Class \Magento\Store\Ui\Component\Form\Field\StoreView |
| 19 | + */ |
| 20 | +class StoreView extends Field |
| 21 | +{ |
| 22 | + /** |
| 23 | + * Store manager |
| 24 | + * |
| 25 | + * @var StoreManager |
| 26 | + */ |
| 27 | + private $storeManager; |
| 28 | + |
| 29 | + /** |
| 30 | + * StoreView constructor. |
| 31 | + * |
| 32 | + * @param ContextInterface $context |
| 33 | + * @param UiComponentFactory $uiComponentFactory |
| 34 | + * @param StoreManager $storeManager |
| 35 | + * @param array $components |
| 36 | + * @param array $data |
| 37 | + */ |
| 38 | + public function __construct( |
| 39 | + ContextInterface $context, |
| 40 | + UiComponentFactory $uiComponentFactory, |
| 41 | + StoreManager $storeManager, |
| 42 | + array $components = [], |
| 43 | + array $data = [] |
| 44 | + ) { |
| 45 | + parent::__construct($context, $uiComponentFactory, $components, $data); |
| 46 | + $this->storeManager = $storeManager; |
| 47 | + } |
| 48 | + |
| 49 | + /** |
| 50 | + * Prepare component configuration |
| 51 | + * |
| 52 | + * @return void |
| 53 | + */ |
| 54 | + public function prepare() |
| 55 | + { |
| 56 | + parent::prepare(); |
| 57 | + if ($this->storeManager->isSingleStoreMode()) { |
| 58 | + $this->_data['config']['componentDisabled'] = true; |
| 59 | + } |
| 60 | + } |
| 61 | +} |
0 commit comments