Skip to content

Commit 19a2c78

Browse files
committed
Merge remote-tracking branch 'origin/MAGETWO-33018-Update-API-Framework-Support-Different-ACL-For-Extension-Attributes' into develop
2 parents 1efdc59 + 5eb9b37 commit 19a2c78

File tree

48 files changed

+1512
-398
lines changed

Some content is hidden

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

48 files changed

+1512
-398
lines changed

app/code/Magento/Bundle/etc/data_object.xml renamed to app/code/Magento/Bundle/etc/service_data_attributes.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
* See COPYING.txt for license details.
66
*/
77
-->
8-
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Api/etc/data_object.xsd">
9-
<custom_attributes for="Magento\Catalog\Api\Data\ProductInterface">
8+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Api/etc/service_data_attributes.xsd">
9+
<extension_attributes for="Magento\Catalog\Api\Data\ProductInterface">
1010
<attribute code="bundle_product_options" type="Magento\Bundle\Api\Data\OptionInterface[]" />
11-
</custom_attributes>
11+
</extension_attributes>
1212
</config>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
/**
4+
* Copyright © 2015 Magento. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Api/etc/service_data_attributes.xsd">
9+
<extension_attributes for="Magento\Catalog\Api\Data\ProductInterface">
10+
<!--
11+
Once this is merged with the branch with the CatalogInventory integration, need to make sure the permission
12+
below is actually used.
13+
<attribute code="stock_item" type="Magento\CatalogInventory\Api\Data\StockItemInterface">
14+
<resources>
15+
<resource ref="Magento_CatalogInventory::cataloginventory"/>
16+
</resources>
17+
</attribute>
18+
-->
19+
</extension_attributes>
20+
</config>

app/code/Magento/GiftMessage/etc/data_object.xml renamed to app/code/Magento/GiftMessage/etc/service_data_attributes.xml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
* See COPYING.txt for license details.
66
*/
77
-->
8-
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Api/etc/data_object.xsd">
9-
<custom_attributes for="Magento\Sales\Api\Data\OrderInterface">
8+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Api/etc/service_data_attributes.xsd">
9+
<extension_attributes for="Magento\Sales\Api\Data\OrderInterface">
1010
<attribute code="gift_message" type="Magento\GiftMessage\Api\Data\MessageInterface" />
11-
</custom_attributes>
12-
<custom_attributes for="Magento\Sales\Api\Data\OrderItemInterface">
11+
</extension_attributes>
12+
<extension_attributes for="Magento\Sales\Api\Data\OrderItemInterface">
1313
<attribute code="gift_message" type="Magento\GiftMessage\Api\Data\MessageInterface" />
14-
</custom_attributes>
14+
</extension_attributes>
1515
</config>

app/code/Magento/GroupedProduct/etc/data_object.xml renamed to app/code/Magento/GroupedProduct/etc/service_data_attributes.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
* See COPYING.txt for license details.
66
*/
77
-->
8-
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Api/etc/data_object.xsd">
9-
<custom_attributes for="Magento\Catalog\Api\Data\ProductLinkInterface">
8+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Api/etc/service_data_attributes.xsd">
9+
<extension_attributes for="Magento\Catalog\Api\Data\ProductLinkInterface">
1010
<attribute code="qty" type="float" />
11-
</custom_attributes>
11+
</extension_attributes>
1212
</config>

app/code/Magento/Sales/etc/data_object.xml renamed to app/code/Magento/Sales/etc/service_data_attributes.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
* See COPYING.txt for license details.
66
*/
77
-->
8-
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Api/etc/data_object.xsd">
9-
<custom_attributes for="Magento\Sales\Api\Data\OrderInterface">
8+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Api/etc/service_data_attributes.xsd">
9+
<extension_attributes for="Magento\Sales\Api\Data\OrderInterface">
1010
<attribute code="applied_taxes" type="Magento\Tax\Api\Data\OrderTaxDetailsAppliedTaxInterface[]" />
1111
<attribute code="item_applied_taxes" type="Magento\Tax\Api\Data\OrderTaxDetailsItemInterface[]" />
1212
<attribute code="converting_from_quote" type="boolean" />
13-
</custom_attributes>
13+
</extension_attributes>
1414
</config>

app/code/Magento/Webapi/Controller/Soap/Request/Handler.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Magento\Webapi\Controller\Soap\Request as SoapRequest;
1616
use Magento\Framework\Webapi\Exception as WebapiException;
1717
use Magento\Webapi\Model\Soap\Config as SoapConfig;
18+
use Magento\Framework\Reflection\MethodsMap;
1819

1920
/**
2021
* Handler of requests to SOAP server.
@@ -48,6 +49,9 @@ class Handler
4849
/** @var DataObjectProcessor */
4950
protected $_dataObjectProcessor;
5051

52+
/** @var MethodsMap */
53+
protected $methodsMapProcessor;
54+
5155
/**
5256
* Initialize dependencies.
5357
*
@@ -58,6 +62,7 @@ class Handler
5862
* @param SimpleDataObjectConverter $dataObjectConverter
5963
* @param ServiceInputProcessor $serviceInputProcessor
6064
* @param DataObjectProcessor $dataObjectProcessor
65+
* @param MethodsMap $methodsMapProcessor
6166
*/
6267
public function __construct(
6368
SoapRequest $request,
@@ -66,7 +71,8 @@ public function __construct(
6671
AuthorizationInterface $authorization,
6772
SimpleDataObjectConverter $dataObjectConverter,
6873
ServiceInputProcessor $serviceInputProcessor,
69-
DataObjectProcessor $dataObjectProcessor
74+
DataObjectProcessor $dataObjectProcessor,
75+
MethodsMap $methodsMapProcessor
7076
) {
7177
$this->_request = $request;
7278
$this->_objectManager = $objectManager;
@@ -75,6 +81,7 @@ public function __construct(
7581
$this->_dataObjectConverter = $dataObjectConverter;
7682
$this->serviceInputProcessor = $serviceInputProcessor;
7783
$this->_dataObjectProcessor = $dataObjectProcessor;
84+
$this->methodsMapProcessor = $methodsMapProcessor;
7885
}
7986

8087
/**
@@ -149,7 +156,7 @@ protected function _prepareRequestData($serviceClass, $serviceMethod, $arguments
149156
protected function _prepareResponseData($data, $serviceClassName, $serviceMethodName)
150157
{
151158
/** @var string $dataType */
152-
$dataType = $this->_dataObjectProcessor->getMethodReturnType($serviceClassName, $serviceMethodName);
159+
$dataType = $this->methodsMapProcessor->getMethodReturnType($serviceClassName, $serviceMethodName);
153160
$result = null;
154161
if (is_object($data)) {
155162
$result = $this->_dataObjectConverter

app/code/Magento/Webapi/Test/Unit/Controller/Soap/Request/HandlerTest.php

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ class HandlerTest extends \PHPUnit_Framework_TestCase
4040
/** @var \Magento\Framework\Reflection\DataObjectProcessor|\PHPUnit_Framework_MockObject_MockObject */
4141
protected $_dataObjectProcessorMock;
4242

43+
/** @var \Magento\Framework\Reflection\MethodsMap|\PHPUnit_Framework_MockObject_MockObject */
44+
protected $_methodsMapProcessorMock;
45+
4346
/** @var array */
4447
protected $_arguments;
4548

@@ -67,7 +70,13 @@ protected function setUp()
6770
);
6871
$this->_dataObjectProcessorMock = $this->getMock(
6972
'Magento\Framework\Reflection\DataObjectProcessor',
70-
['getMethodReturnType'],
73+
[],
74+
[],
75+
'',
76+
false);
77+
$this->_methodsMapProcessorMock = $this->getMock(
78+
'Magento\Framework\Reflection\MethodsMap',
79+
[],
7180
[],
7281
'',
7382
false);
@@ -80,7 +89,8 @@ protected function setUp()
8089
$this->_authorizationMock,
8190
$this->_dataObjectConverter,
8291
$this->_serviceInputProcessorMock,
83-
$this->_dataObjectProcessorMock
92+
$this->_dataObjectProcessorMock,
93+
$this->_methodsMapProcessorMock
8494
);
8595
parent::setUp();
8696
}
@@ -128,10 +138,6 @@ public function testCall()
128138
->method('process')
129139
->will($this->returnArgument(2));
130140

131-
$this->_dataObjectProcessorMock->expects($this->any())->method('getMethodReturnType')
132-
->with($className, $methodName)
133-
->will($this->returnValue('string'));
134-
135141
/** Execute SUT. */
136142
$this->assertEquals(
137143
['result' => $serviceResponse],

app/code/Magento/Webapi/Test/Unit/Model/DataObjectProcessorTest.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,21 @@ class DataObjectProcessorTest extends \PHPUnit_Framework_TestCase
2323
protected function setup()
2424
{
2525
$objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
26-
$this->dataObjectProcessor = $objectManager->getObject('Magento\Framework\Reflection\DataObjectProcessor');
26+
$methodsMapProcessor = $objectManager->getObject(
27+
'Magento\Framework\Reflection\MethodsMap',
28+
[
29+
'fieldNamer' => $objectManager->getObject('Magento\Framework\Reflection\FieldNamer'),
30+
'typeProcessor' => $objectManager->getObject('Magento\Framework\Reflection\TypeProcessor'),
31+
]
32+
);
33+
$this->dataObjectProcessor = $objectManager->getObject(
34+
'Magento\Framework\Reflection\DataObjectProcessor',
35+
[
36+
'methodsMapProcessor' => $methodsMapProcessor,
37+
'typeCaster' => $objectManager->getObject('Magento\Framework\Reflection\TypeCaster'),
38+
'fieldNamer' => $objectManager->getObject('Magento\Framework\Reflection\FieldNamer'),
39+
]
40+
);
2741
parent::setUp();
2842
}
2943

app/code/Magento/Webapi/Test/Unit/Model/Files/TestDataInterface.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,23 @@
88

99
interface TestDataInterface
1010
{
11+
/**
12+
* @return string
13+
*/
1114
public function getId();
1215

16+
/**
17+
* @return string
18+
*/
1319
public function getAddress();
1420

21+
/**
22+
* @return string
23+
*/
1524
public function isDefaultShipping();
1625

26+
/**
27+
* @return string
28+
*/
1729
public function isRequiredBilling();
1830
}

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,17 @@
2222
<type name="Magento\Framework\Xml\Parser" shared="false" />
2323
<type name="Magento\Framework\Code\Scanner\DirectoryScanner" shared="false" />
2424
<type name="Magento\Server\Reflection" shared="false" />
25-
<type name="Magento\Framework\Reflection\DataObjectProcessor">
25+
<type name="Magento\Framework\Reflection\MethodsMap">
2626
<arguments>
2727
<argument name="cache" xsi:type="object">Magento\Framework\App\Cache\Type\Webapi</argument>
2828
</arguments>
2929
</type>
30+
<type name="Magento\Framework\Reflection\DataObjectProcessor">
31+
<arguments>
32+
<argument name="extensionAttributesProcessor" xsi:type="object">Magento\Framework\Reflection\ExtensionAttributesProcessor\Proxy</argument>
33+
<argument name="customAttributesProcessor" xsi:type="object">Magento\Framework\Reflection\CustomAttributesProcessor\Proxy</argument>
34+
</arguments>
35+
</type>
3036
<type name="Magento\Integration\Model\ConfigBasedIntegrationManager">
3137
<plugin name="webapiSetup" type="Magento\Webapi\Model\Plugin\Manager" />
3238
</type>

0 commit comments

Comments
 (0)