Skip to content

Commit c68cdcd

Browse files
committed
Merge remote-tracking branch 'origin/MAGETWO-31929-Extension-Attributes-Generation' into develop
2 parents de7da4f + dd69729 commit c68cdcd

File tree

60 files changed

+1065
-334
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+1065
-334
lines changed

app/code/Magento/Catalog/Model/Category/AttributeRepository.php

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,15 @@ class AttributeRepository implements CategoryAttributeRepositoryInterface
2525
protected $eavAttributeRepository;
2626

2727
/**
28-
* @param \Magento\Framework\Api\Config\MetadataConfig $metadataConfig
2928
* @param \Magento\Framework\Api\SearchCriteriaDataBuilder $searchCriteriaBuilder
3029
* @param \Magento\Framework\Api\FilterBuilder $filterBuilder
3130
* @param \Magento\Eav\Api\AttributeRepositoryInterface $eavAttributeRepository
3231
*/
3332
public function __construct(
34-
\Magento\Framework\Api\Config\MetadataConfig $metadataConfig,
3533
\Magento\Framework\Api\SearchCriteriaDataBuilder $searchCriteriaBuilder,
3634
\Magento\Framework\Api\FilterBuilder $filterBuilder,
3735
\Magento\Eav\Api\AttributeRepositoryInterface $eavAttributeRepository
3836
) {
39-
$this->metadataConfig = $metadataConfig;
4037
$this->searchCriteriaBuilder = $searchCriteriaBuilder;
4138
$this->filterBuilder = $filterBuilder;
4239
$this->eavAttributeRepository = $eavAttributeRepository;
@@ -66,6 +63,7 @@ public function get($attributeCode)
6663

6764
/**
6865
* {@inheritdoc}
66+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
6967
*/
7068
public function getCustomAttributesMetadata($dataObjectClassName = null)
7169
{
@@ -78,12 +76,6 @@ public function getCustomAttributesMetadata($dataObjectClassName = null)
7876
]
7977
);
8078

81-
$customAttributes = [];
82-
$entityAttributes = $this->getList($searchCriteria->create())->getItems();
83-
84-
foreach ($entityAttributes as $attributeMetadata) {
85-
$customAttributes[] = $attributeMetadata;
86-
}
87-
return array_merge($customAttributes, $this->metadataConfig->getCustomAttributesMetadata($dataObjectClassName));
79+
return $this->getList($searchCriteria->create())->getItems();
8880
}
8981
}

app/code/Magento/Catalog/Model/Product/Attribute/Repository.php

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,6 @@ class Repository implements \Magento\Catalog\Api\ProductAttributeRepositoryInter
4949
*/
5050
protected $filterManager;
5151

52-
/**
53-
* @var \Magento\Framework\Api\Config\MetadataConfig
54-
*/
55-
protected $metadataConfig;
56-
5752
/**
5853
* @var \Magento\Framework\Api\SearchCriteriaDataBuilder
5954
*/
@@ -72,7 +67,6 @@ class Repository implements \Magento\Catalog\Api\ProductAttributeRepositoryInter
7267
* @param \Magento\Eav\Api\AttributeRepositoryInterface $eavAttributeRepository
7368
* @param \Magento\Eav\Model\Config $eavConfig
7469
* @param \Magento\Eav\Model\Adminhtml\System\Config\Source\Inputtype\ValidatorFactory $validatorFactory
75-
* @param \Magento\Framework\Api\Config\MetadataConfig $metadataConfig
7670
* @param \Magento\Framework\Api\SearchCriteriaDataBuilder $searchCriteriaBuilder
7771
* @param \Magento\Framework\Api\FilterBuilder $filterBuilder
7872
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
@@ -85,7 +79,6 @@ public function __construct(
8579
\Magento\Eav\Api\AttributeRepositoryInterface $eavAttributeRepository,
8680
\Magento\Eav\Model\Config $eavConfig,
8781
\Magento\Eav\Model\Adminhtml\System\Config\Source\Inputtype\ValidatorFactory $validatorFactory,
88-
\Magento\Framework\Api\Config\MetadataConfig $metadataConfig,
8982
\Magento\Framework\Api\SearchCriteriaDataBuilder $searchCriteriaBuilder,
9083
\Magento\Framework\Api\FilterBuilder $filterBuilder
9184
) {
@@ -96,7 +89,6 @@ public function __construct(
9689
$this->eavAttributeRepository = $eavAttributeRepository;
9790
$this->eavConfig = $eavConfig;
9891
$this->inputtypeValidatorFactory = $validatorFactory;
99-
$this->metadataConfig = $metadataConfig;
10092
$this->searchCriteriaBuilder = $searchCriteriaBuilder;
10193
$this->filterBuilder = $filterBuilder;
10294
}
@@ -224,6 +216,7 @@ public function deleteById($attributeCode)
224216

225217
/**
226218
* {@inheritdoc}
219+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
227220
*/
228221
public function getCustomAttributesMetadata($dataObjectClassName = null)
229222
{
@@ -236,13 +229,7 @@ public function getCustomAttributesMetadata($dataObjectClassName = null)
236229
]
237230
);
238231

239-
$customAttributes = [];
240-
$entityAttributes = $this->getList($searchCriteria->create())->getItems();
241-
242-
foreach ($entityAttributes as $attributeMetadata) {
243-
$customAttributes[] = $attributeMetadata;
244-
}
245-
return array_merge($customAttributes, $this->metadataConfig->getCustomAttributesMetadata($dataObjectClassName));
232+
return $this->getList($searchCriteria->create())->getItems();
246233
}
247234

248235
/**

app/code/Magento/Customer/Model/Metadata/AddressMetadata.php

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
use Magento\Customer\Model\AttributeMetadataConverter;
1111
use Magento\Customer\Model\AttributeMetadataDataProvider;
1212
use Magento\Eav\Model\Entity\Attribute\AbstractAttribute;
13-
use Magento\Framework\Api\Config\MetadataConfig;
1413
use Magento\Framework\Api\SimpleDataObjectConverter;
1514
use Magento\Framework\Exception\NoSuchEntityException;
1615

@@ -24,11 +23,6 @@ class AddressMetadata implements AddressMetadataInterface
2423
*/
2524
private $addressDataObjectMethods;
2625

27-
/**
28-
* @var MetadataConfig
29-
*/
30-
private $metadataConfig;
31-
3226
/**
3327
* @var AttributeMetadataConverter
3428
*/
@@ -40,16 +34,13 @@ class AddressMetadata implements AddressMetadataInterface
4034
private $attributeMetadataDataProvider;
4135

4236
/**
43-
* @param MetadataConfig $metadataConfig
4437
* @param AttributeMetadataConverter $attributeMetadataConverter
4538
* @param AttributeMetadataDataProvider $attributeMetadataDataProvider
4639
*/
4740
public function __construct(
48-
MetadataConfig $metadataConfig,
4941
AttributeMetadataConverter $attributeMetadataConverter,
5042
AttributeMetadataDataProvider $attributeMetadataDataProvider
5143
) {
52-
$this->metadataConfig = $metadataConfig;
5344
$this->attributeMetadataConverter = $attributeMetadataConverter;
5445
$this->attributeMetadataDataProvider = $attributeMetadataDataProvider;
5546
}
@@ -127,14 +118,14 @@ public function getAllAttributesMetadata()
127118
*/
128119
public function getCustomAttributesMetadata($dataObjectClassName = AddressMetadataInterface::DATA_INTERFACE_NAME)
129120
{
130-
$customAttributes = [];
131121
if (!$this->addressDataObjectMethods) {
132122
$dataObjectMethods = array_flip(get_class_methods($dataObjectClassName));
133123
$baseClassDataObjectMethods = array_flip(
134124
get_class_methods('Magento\Framework\Api\AbstractExtensibleObject')
135125
);
136126
$this->addressDataObjectMethods = array_diff_key($dataObjectMethods, $baseClassDataObjectMethods);
137127
}
128+
$customAttributes = [];
138129
foreach ($this->getAllAttributesMetadata() as $attributeMetadata) {
139130
$attributeCode = $attributeMetadata->getAttributeCode();
140131
$camelCaseKey = SimpleDataObjectConverter::snakeCaseToUpperCamelCase($attributeCode);
@@ -145,6 +136,6 @@ public function getCustomAttributesMetadata($dataObjectClassName = AddressMetada
145136
$customAttributes[] = $attributeMetadata;
146137
}
147138
}
148-
return array_merge($customAttributes, $this->metadataConfig->getCustomAttributesMetadata($dataObjectClassName));
139+
return $customAttributes;
149140
}
150141
}

app/code/Magento/Customer/Model/Metadata/CustomerMetadata.php

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
use Magento\Customer\Model\AttributeMetadataConverter;
1111
use Magento\Customer\Model\AttributeMetadataDataProvider;
1212
use Magento\Eav\Model\Entity\Attribute\AbstractAttribute;
13-
use Magento\Framework\Api\Config\MetadataConfig;
1413
use Magento\Framework\Api\SimpleDataObjectConverter;
1514
use Magento\Framework\Exception\NoSuchEntityException;
1615

@@ -24,11 +23,6 @@ class CustomerMetadata implements CustomerMetadataInterface
2423
*/
2524
private $customerDataObjectMethods;
2625

27-
/**
28-
* @var MetadataConfig
29-
*/
30-
private $metadataConfig;
31-
3226
/**
3327
* @var AttributeMetadataConverter
3428
*/
@@ -40,16 +34,13 @@ class CustomerMetadata implements CustomerMetadataInterface
4034
private $attributeMetadataDataProvider;
4135

4236
/**
43-
* @param MetadataConfig $metadataConfig
4437
* @param AttributeMetadataConverter $attributeMetadataConverter
4538
* @param AttributeMetadataDataProvider $attributeMetadataDataProvider
4639
*/
4740
public function __construct(
48-
MetadataConfig $metadataConfig,
4941
AttributeMetadataConverter $attributeMetadataConverter,
5042
AttributeMetadataDataProvider $attributeMetadataDataProvider
5143
) {
52-
$this->metadataConfig = $metadataConfig;
5344
$this->attributeMetadataConverter = $attributeMetadataConverter;
5445
$this->attributeMetadataDataProvider = $attributeMetadataDataProvider;
5546
}
@@ -148,6 +139,6 @@ public function getCustomAttributesMetadata($dataObjectClassName = self::DATA_IN
148139
$customAttributes[] = $attributeMetadata;
149140
}
150141
}
151-
return array_merge($customAttributes, $this->metadataConfig->getCustomAttributesMetadata($dataObjectClassName));
142+
return $customAttributes;
152143
}
153144
}

app/code/Magento/Customer/etc/di.xml

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -83,26 +83,6 @@
8383
</argument>
8484
</arguments>
8585
</type>
86-
<virtualType name="Magento\Customer\Api\Config\CustomerMetadataConfig" type="Magento\Framework\Api\Config\MetadataConfig">
87-
<arguments>
88-
<argument name="attributeMetadataBuilder" xsi:type="object">Magento\Customer\Model\AttributeMetadataDataBuilder</argument>
89-
</arguments>
90-
</virtualType>
91-
<type name="Magento\Customer\Model\Metadata\CustomerMetadata">
92-
<arguments>
93-
<argument name="metadataConfig" xsi:type="object">Magento\Customer\Api\Config\CustomerMetadataConfig</argument>
94-
</arguments>
95-
</type>
96-
<virtualType name="Magento\Customer\Api\Config\AddressMetadataConfig" type="Magento\Framework\Api\Config\MetadataConfig">
97-
<arguments>
98-
<argument name="attributeMetadataBuilder" xsi:type="object">Magento\Customer\Model\AttributeMetadataDataBuilder</argument>
99-
</arguments>
100-
</virtualType>
101-
<type name="Magento\Customer\Model\Metadata\AddressMetadata">
102-
<arguments>
103-
<argument name="metadataConfig" xsi:type="object">Magento\Customer\Api\Config\AddressMetadataConfig</argument>
104-
</arguments>
105-
</type>
10686
<type name="Magento\Framework\Model\ActionValidator\RemoveAction">
10787
<arguments>
10888
<argument name="protectedModels" xsi:type="array">

app/etc/di.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282
<preference for="Magento\Framework\Mview\View\ChangelogInterface" type="Magento\Framework\Mview\View\Changelog" />
8383
<preference for="Magento\Framework\View\Design\FileResolution\Fallback\CacheDataInterface" type="Magento\Framework\View\Design\FileResolution\Fallback\CacheData\Flat"/>
8484
<preference for="Magento\Framework\Api\AttributeMetadataBuilderInterface" type="Magento\Framework\Api\AttributeMetadataBuilder"/>
85-
<preference for="Magento\Framework\Api\MetadataServiceInterface" type="Magento\Framework\Api\Config\MetadataConfig"/>
85+
<preference for="Magento\Framework\Api\MetadataServiceInterface" type="Magento\Framework\Api\DefaultMetadataService"/>
8686
<preference for="Magento\Framework\Api\SearchCriteriaInterface" type="Magento\Framework\Api\SearchCriteria"/>
8787
<preference for="Magento\Framework\App\Rss\UrlBuilderInterface" type="Magento\Framework\App\Rss\UrlBuilder"/>
8888
<preference for="Magento\Framework\DB\LoggerInterface" type="Magento\Framework\DB\Logger\Null"/>

dev/tests/api-functional/_files/Magento/TestModule1/etc/di.xml

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,4 @@
88
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd">
99
<preference for="Magento\TestModule1\Service\V1\AllSoapAndRestInterface" type="Magento\TestModule1\Service\V1\AllSoapAndRest" />
1010
<preference for="Magento\TestModule1\Service\V2\AllSoapAndRestInterface" type="Magento\TestModule1\Service\V2\AllSoapAndRest" />
11-
12-
<virtualType name="Magento\TestModule1\Service\Config\TestModule1MetadataConfig" type="Magento\Framework\Api\Config\MetadataConfig">
13-
<arguments>
14-
<argument name="attributeMetadataBuilder" xsi:type="object">Magento\TestModule1\Service\V1\Entity\Eav\AttributeMetadataBuilder</argument>
15-
<argument name="dataObjectClassName" xsi:type="string">Magento\TestModule1\Service\V1\Entity\Item</argument>
16-
</arguments>
17-
</virtualType>
18-
<type name="Magento\TestModule1\Service\V1\Entity\ItemBuilder">
19-
<arguments>
20-
<argument name="metadataService" xsi:type="object">Magento\TestModule1\Service\Config\TestModule1MetadataConfig</argument>
21-
</arguments>
22-
</type>
2311
</config>

dev/tests/api-functional/_files/Magento/TestModuleMSC/etc/di.xml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,9 @@
1313
<preference for="Magento\TestModuleMSC\Api\Data\CustomAttributeDataObjectInterface" type="Magento\TestModuleMSC\Model\Data\CustomAttributeDataObject" />
1414
<preference for="Magento\TestModuleMSC\Api\Data\CustomAttributeNestedDataObjectInterface" type="Magento\TestModuleMSC\Model\Data\CustomAttributeNestedDataObject" />
1515

16-
<virtualType name="Magento\TestModuleMSC\Service\Config\TestModuleMSCMetadataConfig" type="Magento\Framework\Api\Config\MetadataConfig">
17-
<arguments>
18-
<argument name="attributeMetadataBuilder" xsi:type="object">Magento\TestModuleMSC\Model\Data\Eav\AttributeMetadataBuilder</argument>
19-
<argument name="dataObjectClassName" xsi:type="string">Magento\TestModuleMSC\Model\Data\Item</argument>
20-
</arguments>
21-
</virtualType>
2216
<type name="Magento\TestModuleMSC\Model\Data\Item">
2317
<arguments>
2418
<argument name="resource" xsi:type="object">Magento\TestModuleMSC\Model\Resource\Item</argument>
25-
<argument name="metadataService" xsi:type="object">Magento\TestModuleMSC\Service\Config\TestModuleMSCMetadataConfig</argument>
2619
</arguments>
2720
</type>
2821
<type name="Magento\TestModuleMSC\Model\Data\CustomAttributeDataObject">

dev/tests/integration/testsuite/Magento/Customer/Model/AddressMetadataTest.php

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,7 @@ protected function setUp()
3131
public function testGetCustomAttributesMetadata()
3232
{
3333
$customAttributesMetadata = $this->_service->getCustomAttributesMetadata();
34-
$this->assertCount(2, $customAttributesMetadata, "Invalid number of attributes returned.");
35-
$configAttributeCode = 'address_attribute_1';
36-
$configAttributeFound = false;
37-
foreach ($customAttributesMetadata as $attribute) {
38-
if ($attribute->getAttributeCode() == $configAttributeCode) {
39-
$configAttributeFound = true;
40-
break;
41-
}
42-
}
43-
if (!$configAttributeFound) {
44-
$this->fail("Custom attribute declared in the config not found.");
45-
}
34+
$this->assertCount(0, $customAttributesMetadata, "Invalid number of attributes returned.");
4635
}
4736

4837
/**
@@ -69,7 +58,7 @@ public function testGetCustomAttributesMetadataWithAttributeNamedCustomAttribute
6958
if (!$customAttributesFound) {
7059
$this->fail("Custom attributes declared in the config not found.");
7160
}
72-
$this->assertCount(4, $customAttributesMetadata, "Invalid number of attributes returned.");
61+
$this->assertCount(2, $customAttributesMetadata, "Invalid number of attributes returned.");
7362
}
7463

7564
public function testGetAddressAttributeMetadata()

dev/tests/integration/testsuite/Magento/Customer/Model/CustomerMetadataTest.php

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -47,18 +47,7 @@ protected function setUp()
4747
public function testGetCustomAttributesMetadata()
4848
{
4949
$customAttributesMetadata = $this->_service->getCustomAttributesMetadata();
50-
$this->assertCount(3, $customAttributesMetadata, "Invalid number of attributes returned.");
51-
$configAttributeCode = 'customer_attribute_1';
52-
$configAttributeFound = false;
53-
foreach ($customAttributesMetadata as $attribute) {
54-
if ($attribute->getAttributeCode() == $configAttributeCode) {
55-
$configAttributeFound = true;
56-
break;
57-
}
58-
}
59-
if (!$configAttributeFound) {
60-
$this->fail("Custom attribute declared in the config not found.");
61-
}
50+
$this->assertCount(1, $customAttributesMetadata, "Invalid number of attributes returned.");
6251
}
6352

6453
public function testGetNestedOptionsCustomAttributesMetadata()
@@ -104,7 +93,7 @@ public function testGetCustomAttributesMetadataWithAttributeNamedCustomAttribute
10493
if (!$customAttributesFound) {
10594
$this->fail("Custom attributes declared in the config not found.");
10695
}
107-
$this->assertCount(5, $customAttributesMetadata, "Invalid number of attributes returned.");
96+
$this->assertCount(3, $customAttributesMetadata, "Invalid number of attributes returned.");
10897
}
10998

11099
/**

0 commit comments

Comments
 (0)