Magento Extensions Rating 2024
EXTENSIONS BY CATEGORY
B2B (Business-To-Business)
Blog
Customer
ERP (Enterprise Resource Planning)
Mega Menu
One Step Checkout
Order
POS (Point Of Sale)
Search
Shopping Cart
Sitemap
SEO
Social
Stock & Inventory Management
EXTENSIONS BY DEVELOPER
aheadWorks
Amasty
Boost My Shop
BSS Commerce
Magestore
MageWorx
Mirasvit
Templates Master
Wyomind
XTENTO
Magento 2 Documentation
Magento 2 Documentation
2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
vendor
magento
module-inventory-catalog-admin-ui
Plugin
InventoryAdminUi
DataProvider
PreventDisablingDefaultSourcePlugin.php
Go to the documentation of this file.
1
<?php
6
declare(strict_types=1);
7
8
namespace
Magento\InventoryCatalogAdminUi\Plugin\InventoryAdminUi\DataProvider
;
9
10
use
Magento\Framework\App\RequestInterface
;
11
use
Magento\InventoryApi\Api\Data\SourceItemInterface
;
12
use
Magento\InventoryCatalogApi\Api\DefaultSourceProviderInterface
;
13
use
Magento\InventoryAdminUi\Ui\DataProvider\SourceDataProvider
;
14
15
class
PreventDisablingDefaultSourcePlugin
16
{
20
private
$defaultSourceProvider;
21
25
private
$request;
26
31
public
function
__construct
(
32
DefaultSourceProviderInterface
$defaultSourceProvider,
33
RequestInterface
$request
34
) {
35
$this->defaultSourceProvider =
$defaultSourceProvider
;
36
$this->request =
$request
;
37
}
38
44
public
function
afterGetMeta
(
45
SourceDataProvider
$subject,
46
$meta
47
): array {
48
$isFormComponent =
SourceDataProvider::SOURCE_FORM_NAME
=== $subject->
getName
();
49
if
(!$isFormComponent || !$this->isDefaultSource()) {
50
return
$meta;
51
}
52
53
$meta[
'general'
] = [
54
'children'
=> [
55
'enabled'
=> [
56
'arguments'
=> [
57
'data'
=> [
58
'config'
=> [
59
'disabled'
=>
true
,
60
]
61
]
62
]
63
]
64
]
65
];
66
67
return
$meta;
68
}
69
73
private
function
isDefaultSource(): bool
74
{
75
$defaultSourceCode = $this->defaultSourceProvider->getCode();
76
$currentSourceCode = $this->request->getParam(
SourceItemInterface::SOURCE_CODE
);
77
return
$defaultSourceCode === $currentSourceCode;
78
}
79
}
Magento\InventoryCatalogAdminUi\Plugin\InventoryAdminUi\DataProvider\PreventDisablingDefaultSourcePlugin\afterGetMeta
afterGetMeta(SourceDataProvider $subject, $meta)
Definition:
PreventDisablingDefaultSourcePlugin.php:44
Magento\Framework\View\Element\UiComponent\DataProvider\DataProvider\getName
getName()
Definition:
DataProvider.php:143
Magento\InventoryCatalogAdminUi\Plugin\InventoryAdminUi\DataProvider\PreventDisablingDefaultSourcePlugin\__construct
__construct(DefaultSourceProviderInterface $defaultSourceProvider, RequestInterface $request)
Definition:
PreventDisablingDefaultSourcePlugin.php:31
Magento\InventoryApi\Api\Data\SourceItemInterface\SOURCE_CODE
const SOURCE_CODE
Definition:
SourceItemInterface.php:26
$defaultSourceProvider
$defaultSourceProvider
Definition:
source_items_on_default_source.php:22
Magento\InventoryApi\Api\Data\SourceItemInterface
Definition:
SourceItemInterface.php:20
Magento\InventoryCatalogAdminUi\Plugin\InventoryAdminUi\DataProvider
Definition:
PreventDisablingDefaultSourcePlugin.php:8
Magento\InventoryCatalogApi\Api\DefaultSourceProviderInterface
Definition:
DefaultSourceProviderInterface.php:15
Magento\Framework\App\RequestInterface
Definition:
RequestInterface.php:14
$request
$request
Definition:
quote_with_configurable_product_last_variation.php:22
Magento\InventoryCatalogAdminUi\Plugin\InventoryAdminUi\DataProvider\PreventDisablingDefaultSourcePlugin
Definition:
PreventDisablingDefaultSourcePlugin.php:15
Magento\InventoryAdminUi\Ui\DataProvider\SourceDataProvider\SOURCE_FORM_NAME
const SOURCE_FORM_NAME
Definition:
SourceDataProvider.php:25
Magento\InventoryAdminUi\Ui\DataProvider\SourceDataProvider
Definition:
SourceDataProvider.php:23