Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Record.php
Go to the documentation of this file.
1 <?php
6 declare(strict_types=1);
7 
9 
15 
16 class Record extends Container
17 {
21  private $defaultStockProvider;
22 
29  public function __construct(
31  DefaultStockProviderInterface $defaultStockProvider,
32  array $components = [],
33  array $data = []
34  ) {
35  parent::__construct($context, $components, $data);
36  $this->defaultStockProvider = $defaultStockProvider;
37  }
38 
42  public function prepare()
43  {
44  parent::prepare();
45 
46  // Disable assign sources if stock is default
47  $stockId = (int) $this->context->getRequestParam(StockInterface::STOCK_ID);
48  if ($stockId === $this->defaultStockProvider->getId()) {
49  $deleteConfig = $this->components['actionDelete']->getData('config');
50  $deleteConfig['disabled'] = true;
51  $deleteConfig['notice'] = __('Disabled for default stock');
52  $this->components['actionDelete']->setData('config', $deleteConfig);
53  }
54  }
55 }
__construct(ContextInterface $context, DefaultStockProviderInterface $defaultStockProvider, array $components=[], array $data=[])
Definition: Record.php:29
__()
Definition: __.php:13