Skip to content

Commit 69b4f03

Browse files
committed
Merge remote-tracking branch 'mainline/develop' into develop
2 parents 253d102 + 5b465a2 commit 69b4f03

File tree

23 files changed

+176
-66
lines changed

23 files changed

+176
-66
lines changed

app/code/Magento/Catalog/Api/ProductRepositoryInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function save(\Magento\Catalog\Api\Data\ProductInterface $product, $saveO
2929
*
3030
* @param string $sku
3131
* @param bool $editMode
32-
* @param null|int $storeId
32+
* @param int|null $storeId
3333
* @param bool $forceReload
3434
* @return \Magento\Catalog\Api\Data\ProductInterface
3535
* @throws \Magento\Framework\Exception\NoSuchEntityException

app/code/Magento/Quote/Api/GuestCartTotalManagementInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ interface GuestCartTotalManagementInterface
1414
* Set shipping/billing methods and additional data for cart and collect totals for guest.
1515
*
1616
* @param string $cartId The cart ID.
17-
* @param \Magento\Quote\Api\Data\PaymentInterface Payment method data.
17+
* @param \Magento\Quote\Api\Data\PaymentInterface $paymentMethod Payment method data.
1818
* @param string $shippingCarrierCode The carrier code.
1919
* @param string $shippingMethodCode The shipping method code.
2020
* @param \Magento\Quote\Api\Data\TotalsAdditionalDataInterface $additionalData Additional data to collect totals.

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

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,11 @@ class Soap implements \Magento\Framework\App\FrontControllerInterface
6969
protected $areaList;
7070

7171
/**
72-
* Initialize dependencies.
73-
*
72+
* @var \Magento\Framework\Webapi\Rest\Response\RendererFactory
73+
*/
74+
protected $rendererFactory;
75+
76+
/**
7477
* @param Soap\Request $request
7578
* @param Response $response
7679
* @param \Magento\Webapi\Model\Soap\Wsdl\Generator $wsdlGenerator
@@ -79,7 +82,9 @@ class Soap implements \Magento\Framework\App\FrontControllerInterface
7982
* @param \Magento\Framework\App\State $appState
8083
* @param \Magento\Framework\Locale\ResolverInterface $localeResolver
8184
* @param PathProcessor $pathProcessor
85+
* @param \Magento\Framework\Webapi\Rest\Response\RendererFactory $rendererFactory
8286
* @param \Magento\Framework\App\AreaList $areaList
87+
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
8388
*/
8489
public function __construct(
8590
\Magento\Webapi\Controller\Soap\Request $request,
@@ -90,6 +95,7 @@ public function __construct(
9095
\Magento\Framework\App\State $appState,
9196
\Magento\Framework\Locale\ResolverInterface $localeResolver,
9297
PathProcessor $pathProcessor,
98+
\Magento\Framework\Webapi\Rest\Response\RendererFactory $rendererFactory,
9399
\Magento\Framework\App\AreaList $areaList
94100
) {
95101
$this->_request = $request;
@@ -101,6 +107,7 @@ public function __construct(
101107
$this->_localeResolver = $localeResolver;
102108
$this->_pathProcessor = $pathProcessor;
103109
$this->areaList = $areaList;
110+
$this->rendererFactory = $rendererFactory;
104111
}
105112

106113
/**
@@ -122,6 +129,15 @@ public function dispatch(\Magento\Framework\App\RequestInterface $request)
122129
);
123130
$this->_setResponseContentType(self::CONTENT_TYPE_WSDL_REQUEST);
124131
$this->_setResponseBody($responseBody);
132+
} else if ($this->_isWsdlListRequest()) {
133+
$servicesList = [];
134+
foreach (array_keys($this->_wsdlGenerator->getListOfServices()) as $serviceName) {
135+
$servicesList[$serviceName]['wsdl_endpoint'] = $this->_soapServer->getEndpointUri()
136+
. '?' . \Magento\Webapi\Model\Soap\Server::REQUEST_PARAM_WSDL . '&services=' . $serviceName;
137+
}
138+
$renderer = $this->rendererFactory->get();
139+
$this->_setResponseContentType($renderer->getMimeType());
140+
$this->_setResponseBody($renderer->render($servicesList));
125141
} else {
126142
$this->_soapServer->handle();
127143
}
@@ -141,6 +157,16 @@ protected function _isWsdlRequest()
141157
return $this->_request->getParam(\Magento\Webapi\Model\Soap\Server::REQUEST_PARAM_WSDL) !== null;
142158
}
143159

160+
/**
161+
* Check if current request is WSDL request. SOAP operation execution request is another type of requests.
162+
*
163+
* @return bool
164+
*/
165+
protected function _isWsdlListRequest()
166+
{
167+
return $this->_request->getParam(\Magento\Webapi\Model\Soap\Server::REQUEST_PARAM_LIST_WSDL) !== null;
168+
}
169+
144170
/**
145171
* Parse the Authorization header and return the access token e.g. Authorization: Bearer <access-token>
146172
*

app/code/Magento/Webapi/Model/Soap/Config.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ protected function getSoapOperations($requestedServices)
141141
*
142142
* @return array
143143
*/
144-
protected function getSoapServicesConfig()
144+
public function getSoapServicesConfig()
145145
{
146146
if (null === $this->soapServices) {
147147
$soapServicesConfig = $this->cache->load(self::CACHE_ID);

app/code/Magento/Webapi/Model/Soap/Config/ClassReflector.php

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
*/
66
namespace Magento\Webapi\Model\Soap\Config;
77

8-
use Zend\Server\Reflection;
9-
use Zend\Server\Reflection\ReflectionMethod;
108
use Zend\Code\Reflection\MethodReflection;
119

1210
/**
@@ -66,8 +64,8 @@ public function __construct(\Magento\Framework\Reflection\TypeProcessor $typePro
6664
public function reflectClassMethods($className, $methods)
6765
{
6866
$data = [];
69-
$classReflection = new \Zend\Server\Reflection\ReflectionClass(new \ReflectionClass($className));
70-
/** @var $methodReflection ReflectionMethod */
67+
$classReflection = new \Zend\Code\Reflection\ClassReflection($className);
68+
/** @var \Zend\Code\Reflection\MethodReflection $methodReflection */
7169
foreach ($classReflection->getMethods() as $methodReflection) {
7270
$methodName = $methodReflection->getName();
7371
if (array_key_exists($methodName, $methods)) {
@@ -80,33 +78,30 @@ public function reflectClassMethods($className, $methods)
8078
/**
8179
* Retrieve method interface and documentation description.
8280
*
83-
* @param ReflectionMethod $method
81+
* @param \Zend\Code\Reflection\MethodReflection $method
8482
* @return array
8583
* @throws \InvalidArgumentException
8684
*/
87-
public function extractMethodData(ReflectionMethod $method)
85+
public function extractMethodData(\Zend\Code\Reflection\MethodReflection $method)
8886
{
8987
$methodData = ['documentation' => $this->extractMethodDescription($method), 'interface' => []];
90-
$prototypes = $method->getPrototypes();
91-
/** Take the fullest interface that also includes optional parameters. */
92-
/** @var \Zend\Server\Reflection\Prototype $prototype */
93-
$prototype = end($prototypes);
94-
/** @var \Zend\Server\Reflection\ReflectionParameter $parameter */
95-
foreach ($prototype->getParameters() as $parameter) {
88+
/** @var \Zend\Code\Reflection\ParameterReflection $parameter */
89+
foreach ($method->getParameters() as $parameter) {
9690
$parameterData = [
97-
'type' => $this->_typeProcessor->register($parameter->getType()),
91+
'type' => $this->_typeProcessor->register($this->_typeProcessor->getParamType($parameter)),
9892
'required' => !$parameter->isOptional(),
99-
'documentation' => $parameter->getDescription(),
93+
'documentation' => $this->_typeProcessor->getParamDescription($parameter),
10094
];
10195
if ($parameter->isOptional()) {
10296
$parameterData['default'] = $parameter->getDefaultValue();
10397
}
10498
$methodData['interface']['in']['parameters'][$parameter->getName()] = $parameterData;
10599
}
106-
if ($prototype->getReturnType() != 'void' && $prototype->getReturnType() != 'null') {
100+
$returnType = $this->_typeProcessor->getGetterReturnType($method);
101+
if ($returnType != 'void' && $returnType != 'null') {
107102
$methodData['interface']['out']['parameters']['result'] = [
108-
'type' => $this->_typeProcessor->register($prototype->getReturnType()),
109-
'documentation' => $prototype->getReturnValue()->getDescription(),
103+
'type' => $this->_typeProcessor->register($returnType['type']),
104+
'documentation' => $returnType['description'],
110105
'required' => true,
111106
];
112107
}
@@ -117,10 +112,10 @@ public function extractMethodData(ReflectionMethod $method)
117112
/**
118113
* Retrieve method full documentation description.
119114
*
120-
* @param ReflectionMethod $method
115+
* @param \Zend\Code\Reflection\MethodReflection $method
121116
* @return string
122117
*/
123-
protected function extractMethodDescription(ReflectionMethod $method)
118+
protected function extractMethodDescription(\Zend\Code\Reflection\MethodReflection $method)
124119
{
125120
$methodReflection = new MethodReflection(
126121
$method->getDeclaringClass()->getName(),

app/code/Magento/Webapi/Model/Soap/Server.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ class Server
2121

2222
const REQUEST_PARAM_WSDL = 'wsdl';
2323

24+
const REQUEST_PARAM_LIST_WSDL = 'wsdl_list';
25+
2426
/**
2527
* @var \Magento\Framework\App\AreaLIst
2628
*/

app/code/Magento/Webapi/Model/Soap/Wsdl/Generator.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,16 @@ public function __construct(
8080
$this->customAttributeTypeLocator = $customAttributeTypeLocator;
8181
}
8282

83+
/**
84+
* Retrieve an array of services
85+
*
86+
* @return array
87+
*/
88+
public function getListOfServices()
89+
{
90+
return $this->_apiConfig->getSoapServicesConfig();
91+
}
92+
8393
/**
8494
* Generate WSDL file based on requested services (uses cache)
8595
*

app/code/Magento/Webapi/Test/Unit/Controller/SoapTest.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ class SoapTest extends \PHPUnit_Framework_TestCase
4444
*/
4545
protected $_localeMock;
4646

47+
/**
48+
* @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\App\State
49+
*/
50+
protected $_appStateMock;
51+
4752
/**
4853
* Set up Controller object.
4954
*/
@@ -71,7 +76,8 @@ protected function setUp()
7176
->disableOriginalConstructor()
7277
->setMethods(['maskException'])
7378
->getMock();
74-
$this->_appStateMock = $this->getMock('\Magento\Framework\App\State', [], [], '', false);
79+
80+
$this->_appStateMock = $this->getMock('Magento\Framework\App\State', [], [], '', false);
7581

7682
$localeResolverMock = $this->getMockBuilder(
7783
'Magento\Framework\Locale\Resolver'
@@ -93,6 +99,10 @@ protected function setUp()
9399
$areaListMock = $this->getMock('Magento\Framework\App\AreaList', [], [], '', false);
94100
$areaMock = $this->getMock('Magento\Framework\App\AreaInterface');
95101
$areaListMock->expects($this->any())->method('getArea')->will($this->returnValue($areaMock));
102+
103+
$rendererMock = $this->getMockBuilder('Magento\Framework\Webapi\Rest\Response\RendererFactory')
104+
->disableOriginalConstructor()
105+
->getMock();
96106
$this->_soapController = new \Magento\Webapi\Controller\Soap(
97107
$this->_requestMock,
98108
$this->_responseMock,
@@ -102,6 +112,7 @@ protected function setUp()
102112
$this->_appStateMock,
103113
$localeResolverMock,
104114
$pathProcessorMock,
115+
$rendererMock,
105116
$areaListMock
106117
);
107118
}

app/code/Magento/Webapi/Test/Unit/Model/Soap/Config/ClassReflectorTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@ public function testReflectClassMethods()
4949

5050
public function testExtractMethodData()
5151
{
52-
$classReflection = new \Zend\Server\Reflection\ReflectionClass(
53-
new \ReflectionClass('\\Magento\\Webapi\\Test\\Unit\\Model\\Config\\TestServiceForClassReflector')
52+
$classReflection = new \Zend\Code\Reflection\ClassReflection(
53+
'\\Magento\\Webapi\\Test\\Unit\\Model\\Config\\TestServiceForClassReflector'
5454
);
55-
/** @var $methodReflection ReflectionMethod */
55+
/** @var $methodReflection \Zend\Code\Reflection\MethodReflection */
5656
$methodReflection = $classReflection->getMethods()[0];
5757
$methodData = $this->_classReflector->extractMethodData($methodReflection);
5858
$expectedResponse = $this->_getSampleReflectionData();

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

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,30 @@
4343
</argument>
4444
</arguments>
4545
</type>
46+
<type name="Magento\Framework\Webapi\Rest\Response\RendererFactory">
47+
<arguments>
48+
<argument name="renders" xsi:type="array">
49+
<item name="default" xsi:type="array">
50+
<item name="type" xsi:type="string">*/*</item>
51+
<item name="model" xsi:type="string">Magento\Framework\Webapi\Rest\Response\Renderer\Json</item>
52+
</item>
53+
<item name="application_json" xsi:type="array">
54+
<item name="type" xsi:type="string">application/json</item>
55+
<item name="model" xsi:type="string">Magento\Framework\Webapi\Rest\Response\Renderer\Json</item>
56+
</item>
57+
<item name="text_xml" xsi:type="array">
58+
<item name="type" xsi:type="string">text/xml</item>
59+
<item name="model" xsi:type="string">Magento\Framework\Webapi\Rest\Response\Renderer\Xml</item>
60+
</item>
61+
<item name="application_xml" xsi:type="array">
62+
<item name="type" xsi:type="string">application/xml</item>
63+
<item name="model" xsi:type="string">Magento\Framework\Webapi\Rest\Response\Renderer\Xml</item>
64+
</item>
65+
<item name="application_xhtml_xml" xsi:type="array">
66+
<item name="type" xsi:type="string">application/xhtml+xml</item>
67+
<item name="model" xsi:type="string">Magento\Framework\Webapi\Rest\Response\Renderer\Xml</item>
68+
</item>
69+
</argument>
70+
</arguments>
71+
</type>
4672
</config>

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

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -33,32 +33,6 @@
3333
<preference for="Magento\Framework\App\FrontControllerInterface" type="Magento\Webapi\Controller\Rest" />
3434
<preference for="Magento\Framework\Model\ActionValidator\RemoveAction" type="Magento\Framework\Model\ActionValidator\RemoveAction\Allowed" />
3535
<type name="Magento\Webapi\Controller\Rest\Router\Route" shared="false" />
36-
<type name="Magento\Framework\Webapi\Rest\Response\RendererFactory">
37-
<arguments>
38-
<argument name="renders" xsi:type="array">
39-
<item name="default" xsi:type="array">
40-
<item name="type" xsi:type="string">*/*</item>
41-
<item name="model" xsi:type="string">Magento\Framework\Webapi\Rest\Response\Renderer\Json</item>
42-
</item>
43-
<item name="application_json" xsi:type="array">
44-
<item name="type" xsi:type="string">application/json</item>
45-
<item name="model" xsi:type="string">Magento\Framework\Webapi\Rest\Response\Renderer\Json</item>
46-
</item>
47-
<item name="text_xml" xsi:type="array">
48-
<item name="type" xsi:type="string">text/xml</item>
49-
<item name="model" xsi:type="string">Magento\Framework\Webapi\Rest\Response\Renderer\Xml</item>
50-
</item>
51-
<item name="application_xml" xsi:type="array">
52-
<item name="type" xsi:type="string">application/xml</item>
53-
<item name="model" xsi:type="string">Magento\Framework\Webapi\Rest\Response\Renderer\Xml</item>
54-
</item>
55-
<item name="application_xhtml_xml" xsi:type="array">
56-
<item name="type" xsi:type="string">application/xhtml+xml</item>
57-
<item name="model" xsi:type="string">Magento\Framework\Webapi\Rest\Response\Renderer\Xml</item>
58-
</item>
59-
</argument>
60-
</arguments>
61-
</type>
6236
<type name="Magento\Webapi\Controller\Rest">
6337
<arguments>
6438
<argument name="request" xsi:type="object">Magento\Framework\Webapi\Rest\Request\Proxy</argument>

dev/tests/api-functional/_files/Magento/TestJoinDirectives/Api/TestRepositoryInterface.php renamed to dev/tests/api-functional/_files/Magento/TestModuleJoinDirectives/Api/TestRepositoryInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Copyright © 2015 Magento. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6-
namespace Magento\TestJoinDirectives\Api;
6+
namespace Magento\TestModuleJoinDirectives\Api;
77

88
/**
99
* Interface TestRepositoryInterface

dev/tests/api-functional/_files/Magento/TestJoinDirectives/Model/TestRepository.php renamed to dev/tests/api-functional/_files/Magento/TestModuleJoinDirectives/Model/TestRepository.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
* Copyright © 2015 Magento. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6-
namespace Magento\TestJoinDirectives\Model;
6+
namespace Magento\TestModuleJoinDirectives\Model;
77

8-
use Magento\TestJoinDirectives\Api\TestRepositoryInterface;
8+
use Magento\TestModuleJoinDirectives\Api\TestRepositoryInterface;
99
use Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface;
1010

1111
/**

dev/tests/api-functional/_files/Magento/TestJoinDirectives/etc/acl.xml renamed to dev/tests/api-functional/_files/Magento/TestModuleJoinDirectives/etc/acl.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
<acl>
1010
<resources>
1111
<resource id="Magento_Backend::admin">
12-
<resource id="Magento_TestJoinDirectives::all" title="TestJoinDirectives" sortOrder="1">
13-
<resource id="Magento_TestJoinDirectives::getList" title="GetList" sortOrder="10"/>
12+
<resource id="Magento_TestModuleJoinDirectives::all" title="TestJoinDirectives" sortOrder="1">
13+
<resource id="Magento_TestModuleJoinDirectives::getList" title="GetList" sortOrder="10"/>
1414
</resource>
1515
</resource>
1616
</resources>

dev/tests/api-functional/_files/Magento/TestJoinDirectives/etc/di.xml renamed to dev/tests/api-functional/_files/Magento/TestModuleJoinDirectives/etc/di.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66
*/
77
-->
88
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd">
9-
<preference for="Magento\TestJoinDirectives\Api\TestRepositoryInterface" type="Magento\TestJoinDirectives\Model\TestRepository" />
9+
<preference for="Magento\TestModuleJoinDirectives\Api\TestRepositoryInterface" type="Magento\TestModuleJoinDirectives\Model\TestRepository" />
1010
</config>

dev/tests/api-functional/_files/Magento/TestJoinDirectives/etc/module.xml renamed to dev/tests/api-functional/_files/Magento/TestModuleJoinDirectives/etc/module.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66
*/
77
-->
88
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd">
9-
<module name="Magento_TestJoinDirectives" setup_version="1.0"/>
9+
<module name="Magento_TestModuleJoinDirectives" setup_version="1.0"/>
1010
</config>

dev/tests/api-functional/_files/Magento/TestJoinDirectives/etc/webapi.xml renamed to dev/tests/api-functional/_files/Magento/TestModuleJoinDirectives/etc/webapi.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
<routes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
99
xsi:noNamespaceSchemaLocation="../../../../../app/code/Magento/Webapi/etc/webapi.xsd">
1010

11-
<route url="/V1/TestJoinDirectives" method="GET">
12-
<service class="Magento\TestJoinDirectives\Api\TestRepositoryInterface" method="getList"/>
11+
<route url="/V1/TestModuleJoinDirectives" method="GET">
12+
<service class="Magento\TestModuleJoinDirectives\Api\TestRepositoryInterface" method="getList"/>
1313
<resources>
14-
<resource ref="Magento_TestJoinDirectives::getList" />
14+
<resource ref="Magento_TestModuleJoinDirectives::getList" />
1515
</resources>
1616
</route>
1717
</routes>

dev/tests/api-functional/testsuite/Magento/Webapi/JoinDirectivesTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ public function testGetList()
5454
$searchCriteria = $this->searchBuilder->create()->__toArray();
5555
$requestData = ['searchCriteria' => $searchCriteria];
5656

57-
$restResourcePath = '/V1/TestJoinDirectives/';
58-
$soapService = 'testJoinDirectivesTestRepositoryV1';
57+
$restResourcePath = '/V1/TestModuleJoinDirectives/';
58+
$soapService = 'testModuleJoinDirectivesTestRepositoryV1';
5959
$expectedExtensionAttributes = $this->getExpectedExtensionAttributes();
6060

6161
$serviceInfo = [

0 commit comments

Comments
 (0)