Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
DefaultValue.php
Go to the documentation of this file.
1 <?php
6 declare(strict_types=1);
7 
9 
13 
15 class DefaultValue extends \Magento\Ui\Component\Form\Field
16 {
20  private $scopeConfig;
21 
25  private $path;
26 
30  private $storeManager;
31 
42  public function __construct(
45  ScopeConfigInterface $scopeConfig,
46  \Magento\Store\Model\StoreManagerInterface $storeManager,
47  string $path = '',
48  array $components = [],
49  array $data = []
50  ) {
51  parent::__construct($context, $uiComponentFactory, $components, $data);
52  $this->scopeConfig = $scopeConfig;
53  $this->storeManager = $storeManager;
54  $this->path = $path;
55  }
56 
60  public function prepare()
61  {
62  parent::prepare();
63  $store = $this->storeManager->getStore();
64  $this->_data['config']['default'] = $this->scopeConfig->getValue(
65  $this->path,
66  \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
67  $store
68  );
69  }
70 }
$storeManager
__construct(ContextInterface $context, UiComponentFactory $uiComponentFactory, ScopeConfigInterface $scopeConfig, \Magento\Store\Model\StoreManagerInterface $storeManager, string $path='', array $components=[], array $data=[])