Skip to content

Commit 1c7e9f4

Browse files
committed
Merge pull request magento#112 from magento-api/develop
[API] Sprint 43
2 parents daced02 + a38621a commit 1c7e9f4

File tree

369 files changed

+3674
-2087
lines changed

Some content is hidden

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

369 files changed

+3674
-2087
lines changed

app/code/Magento/Bundle/Api/ProductLinkManagementInterface.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ interface ProductLinkManagementInterface
1414
* @param string $productId
1515
* @return \Magento\Bundle\Api\Data\LinkInterface[]
1616
* @throws \Magento\Framework\Exception\NoSuchEntityException
17-
* @throws \Magento\Webapi\Exception
17+
* @throws \Magento\Framework\Exception\InputException
1818
*/
1919
public function getChildren($productId);
2020

@@ -53,7 +53,7 @@ public function addChild(
5353
* @param int $optionId
5454
* @param string $childSku
5555
* @throws \Magento\Framework\Exception\NoSuchEntityException
56-
* @throws \Magento\Webapi\Exception
56+
* @throws \Magento\Framework\Exception\InputException
5757
* @return bool
5858
*/
5959
public function removeChild($productSku, $optionId, $childSku);

app/code/Magento/Bundle/Api/ProductOptionManagementInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ interface ProductOptionManagementInterface
1414
* @param \Magento\Bundle\Api\Data\OptionInterface $option
1515
* @return int
1616
* @throws \Magento\Framework\Exception\CouldNotSaveException
17-
* @throws \Magento\Webapi\Exception
17+
* @throws \Magento\Framework\Exception\InputException
1818
*/
1919
public function save(\Magento\Bundle\Api\Data\OptionInterface $option);
2020
}

app/code/Magento/Bundle/Api/ProductOptionRepositoryInterface.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ interface ProductOptionRepositoryInterface
1515
* @param int $optionId
1616
* @return \Magento\Bundle\Api\Data\OptionInterface
1717
* @throws \Magento\Framework\Exception\NoSuchEntityException
18-
* @throws \Magento\Webapi\Exception
18+
* @throws \Magento\Framework\Exception\InputException
1919
*/
2020
public function get($productSku, $optionId);
2121

@@ -25,7 +25,7 @@ public function get($productSku, $optionId);
2525
* @param string $productSku
2626
* @return \Magento\Bundle\Api\Data\OptionInterface[]
2727
* @throws \Magento\Framework\Exception\NoSuchEntityException
28-
* @throws \Magento\Webapi\Exception
28+
* @throws \Magento\Framework\Exception\InputException
2929
*/
3030
public function getList($productSku);
3131

@@ -35,7 +35,7 @@ public function getList($productSku);
3535
* @param \Magento\Bundle\Api\Data\OptionInterface $option
3636
* @return bool
3737
* @throws \Magento\Framework\Exception\CouldNotSaveException
38-
* @throws \Magento\Webapi\Exception
38+
* @throws \Magento\Framework\Exception\InputException
3939
*/
4040
public function delete(\Magento\Bundle\Api\Data\OptionInterface $option);
4141

@@ -46,7 +46,7 @@ public function delete(\Magento\Bundle\Api\Data\OptionInterface $option);
4646
* @param int $optionId
4747
* @return bool
4848
* @throws \Magento\Framework\Exception\CouldNotSaveException
49-
* @throws \Magento\Webapi\Exception
49+
* @throws \Magento\Framework\Exception\InputException
5050
*/
5151
public function deleteById($productSku, $optionId);
5252

@@ -57,7 +57,7 @@ public function deleteById($productSku, $optionId);
5757
* @param \Magento\Bundle\Api\Data\OptionInterface $option
5858
* @return int
5959
* @throws \Magento\Framework\Exception\CouldNotSaveException
60-
* @throws \Magento\Webapi\Exception
60+
* @throws \Magento\Framework\Exception\InputException
6161
*/
6262
public function save(
6363
\Magento\Catalog\Api\Data\ProductInterface $product,

app/code/Magento/Bundle/Model/LinkManagement.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,8 @@ public function getChildren($productId)
7171
{
7272
$product = $this->productRepository->get($productId);
7373
if ($product->getTypeId() != \Magento\Catalog\Model\Product\Type::TYPE_BUNDLE) {
74-
throw new \Magento\Webapi\Exception(
75-
'Only implemented for bundle product',
76-
\Magento\Webapi\Exception::HTTP_FORBIDDEN
74+
throw new InputException(
75+
'Only implemented for bundle product'
7776
);
7877
}
7978

@@ -178,9 +177,8 @@ public function removeChild($productSku, $optionId, $childSku)
178177
$product = $this->productRepository->get($productSku);
179178

180179
if ($product->getTypeId() != \Magento\Catalog\Model\Product\Type::TYPE_BUNDLE) {
181-
throw new \Magento\Webapi\Exception(
182-
sprintf('Product with specified sku: %s is not a bundle product', $productSku),
183-
\Magento\Webapi\Exception::HTTP_FORBIDDEN
180+
throw new InputException(
181+
sprintf('Product with specified sku: %s is not a bundle product', $productSku)
184182
);
185183
}
186184

app/code/Magento/Bundle/Model/OptionManagement.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77
namespace Magento\Bundle\Model;
88

9-
use Magento\Webapi\Exception;
9+
use Magento\Framework\Exception\InputException;
1010

1111
class OptionManagement implements \Magento\Bundle\Api\ProductOptionManagementInterface
1212
{
@@ -39,7 +39,7 @@ public function save(\Magento\Bundle\Api\Data\OptionInterface $option)
3939
{
4040
$product = $this->productRepository->get($option->getSku());
4141
if ($product->getTypeId() != \Magento\Catalog\Model\Product\Type::TYPE_BUNDLE) {
42-
throw new Exception('Only implemented for bundle product', Exception::HTTP_FORBIDDEN);
42+
throw new InputException('Only implemented for bundle product');
4343
}
4444
return $this->optionRepository->save($product, $option);
4545
}

app/code/Magento/Bundle/Model/OptionRepository.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
namespace Magento\Bundle\Model;
88

99
use Magento\Framework\Exception\CouldNotSaveException;
10+
use Magento\Framework\Exception\InputException;
1011
use Magento\Framework\Exception\NoSuchEntityException;
11-
use Magento\Webapi\Exception;
1212

1313
/**
1414
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
@@ -205,13 +205,13 @@ public function save(
205205
/**
206206
* @param string $productSku
207207
* @return \Magento\Catalog\Api\Data\ProductInterface
208-
* @throws Exception
208+
* @throws \Magento\Framework\Exception\InputException
209209
*/
210210
private function getProduct($productSku)
211211
{
212212
$product = $this->productRepository->get($productSku);
213213
if ($product->getTypeId() != \Magento\Catalog\Model\Product\Type::TYPE_BUNDLE) {
214-
throw new Exception('Only implemented for bundle product', Exception::HTTP_FORBIDDEN);
214+
throw new InputException('Only implemented for bundle product');
215215
}
216216
return $product;
217217
}

app/code/Magento/Bundle/composer.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,12 @@
1717
"magento/module-eav": "0.42.0-beta10",
1818
"magento/module-gift-message": "0.42.0-beta10",
1919
"magento/framework": "0.42.0-beta10",
20-
"magento/module-webapi": "0.42.0-beta10",
2120
"magento/module-quote": "0.42.0-beta10",
2221
"magento/magento-composer-installer": "*"
2322
},
23+
"suggest": {
24+
"magento/module-webapi": "0.42.0-beta10"
25+
},
2426
"type": "magento2-module",
2527
"version": "0.42.0-beta10",
2628
"license": [

app/code/Magento/ConfigurableProduct/Api/LinkManagementInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function addChild($productSku, $childSku);
2929
* @param string $productSku
3030
* @param string $childSku
3131
* @throws \Magento\Framework\Exception\NoSuchEntityException
32-
* @throws \Magento\Webapi\Exception
32+
* @throws \Magento\Framework\Exception\InputException
3333
* @return bool
3434
*/
3535
public function removeChild($productSku, $childSku);

app/code/Magento/ConfigurableProduct/Api/OptionRepositoryInterface.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ interface OptionRepositoryInterface
1515
* @param int $optionId
1616
* @return \Magento\ConfigurableProduct\Api\Data\OptionInterface
1717
* @throws \Magento\Framework\Exception\NoSuchEntityException
18-
* @throws \Magento\Webapi\Exception
18+
* @throws \Magento\Framework\Exception\InputException
1919
*/
2020
public function get($productSku, $optionId);
2121

@@ -25,14 +25,14 @@ public function get($productSku, $optionId);
2525
* @param string $productSku
2626
* @return \Magento\ConfigurableProduct\Api\Data\OptionInterface[]
2727
* @throws \Magento\Framework\Exception\NoSuchEntityException
28-
* @throws \Magento\Webapi\Exception
28+
* @throws \Magento\Framework\Exception\InputException
2929
*/
3030
public function getList($productSku);
3131

3232
/**
3333
* Remove option from configurable product
3434
*
35-
* @param Data\OptionInterface $option
35+
* @param \Magento\ConfigurableProduct\Api\Data\OptionInterface $option
3636
* @return bool
3737
*/
3838
public function delete(\Magento\ConfigurableProduct\Api\Data\OptionInterface $option);
@@ -44,7 +44,7 @@ public function delete(\Magento\ConfigurableProduct\Api\Data\OptionInterface $op
4444
* @param int $optionId
4545
* @return bool
4646
* @throws \Magento\Framework\Exception\NoSuchEntityException
47-
* @throws \Magento\Webapi\Exception
47+
* @throws \Magento\Framework\Exception\InputException
4848
*/
4949
public function deleteById($productSku, $optionId);
5050

app/code/Magento/ConfigurableProduct/Api/OptionTypesListInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ interface OptionTypesListInterface
1313
*
1414
* @return string[]
1515
* @throws \Magento\Framework\Exception\NoSuchEntityException
16-
* @throws \Magento\Webapi\Exception
16+
* @throws \Magento\Framework\Exception\InputException
1717
*/
1818
public function getItems();
1919
}

app/code/Magento/ConfigurableProduct/Model/LinkManagement.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
*/
77
namespace Magento\ConfigurableProduct\Model;
88

9+
use Magento\Framework\Exception\InputException;
910
use Magento\Framework\Exception\StateException;
1011
use Magento\Framework\Exception\NoSuchEntityException;
11-
use Magento\Webapi\Exception;
1212

1313
class LinkManagement implements \Magento\ConfigurableProduct\Api\LinkManagementInterface
1414
{
@@ -101,9 +101,8 @@ public function removeChild($productSku, $childSku)
101101
$product = $this->productRepository->get($productSku);
102102

103103
if ($product->getTypeId() != \Magento\ConfigurableProduct\Model\Product\Type\Configurable::TYPE_CODE) {
104-
throw new Exception(
105-
sprintf('Product with specified sku: %s is not a configurable product', $productSku),
106-
Exception::HTTP_FORBIDDEN
104+
throw new InputException(
105+
sprintf('Product with specified sku: %s is not a configurable product', $productSku)
107106
);
108107
}
109108

app/code/Magento/ConfigurableProduct/Model/OptionRepository.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
namespace Magento\ConfigurableProduct\Model;
88

99
use Magento\Framework\Exception\NoSuchEntityException;
10-
use Magento\Webapi\Exception;
1110
use Magento\Framework\Exception\StateException;
1211
use Magento\Framework\Exception\InputException;
1312
use Magento\Framework\Exception\CouldNotSaveException;
@@ -241,15 +240,14 @@ public function save($productSku, \Magento\ConfigurableProduct\Api\Data\OptionIn
241240
*
242241
* @param string $productSku
243242
* @return \Magento\Catalog\Model\Product
244-
* @throws \Magento\Webapi\Exception
243+
* @throws InputException
245244
*/
246245
private function getProduct($productSku)
247246
{
248247
$product = $this->productRepository->get($productSku);
249248
if (\Magento\ConfigurableProduct\Model\Product\Type\Configurable::TYPE_CODE !== $product->getTypeId()) {
250-
throw new Exception(
251-
sprintf('Only implemented for configurable product: %s', $productSku),
252-
Exception::HTTP_FORBIDDEN
249+
throw new InputException(
250+
sprintf('Only implemented for configurable product: %s', $productSku)
253251
);
254252
}
255253
return $product;

app/code/Magento/ConfigurableProduct/composer.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@
1515
"magento/module-catalog-rule": "0.42.0-beta10",
1616
"magento/module-directory": "0.42.0-beta10",
1717
"magento/framework": "0.42.0-beta10",
18-
"magento/module-webapi": "0.42.0-beta10",
1918
"magento/module-quote": "0.42.0-beta10",
2019
"magento/magento-composer-installer": "*"
2120
},
21+
"suggest": {
22+
"magento/module-webapi": "0.42.0-beta10"
23+
},
2224
"type": "magento2-module",
2325
"version": "0.42.0-beta10",
2426
"license": [

app/code/Magento/Webapi/Block/Adminhtml/Integration/Activate/Permissions/Tab/Webapi.php renamed to app/code/Magento/Integration/Block/Adminhtml/Integration/Activate/Permissions/Tab/Webapi.php

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
* Copyright © 2015 Magento. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6-
namespace Magento\Webapi\Block\Adminhtml\Integration\Activate\Permissions\Tab;
6+
7+
namespace Magento\Integration\Block\Adminhtml\Integration\Activate\Permissions\Tab;
78

89
use Magento\Integration\Block\Adminhtml\Integration\Edit\Tab\Info;
910
use Magento\Integration\Controller\Adminhtml\Integration as IntegrationController;
1011
use Magento\Integration\Model\Integration as IntegrationModel;
11-
use Magento\Webapi\Helper\Data as WebapiHelper;
1212

1313
/**
1414
* API permissions tab for integration activation dialog.
@@ -28,41 +28,41 @@ class Webapi extends \Magento\Backend\Block\Widget\Form\Generic implements
2828
/** @var \Magento\Integration\Helper\Data */
2929
protected $_integrationData;
3030

31-
/** @var WebapiHelper */
32-
protected $_webapiHelper;
31+
/** @var \Magento\Framework\Json\Encoder */
32+
protected $encoder;
3333

34-
/** @var \Magento\Core\Helper\Data */
35-
protected $_coreHelper;
34+
/** @var \Magento\Integration\Service\V1\Integration */
35+
protected $integrationService;
3636

3737
/**
3838
* Initialize dependencies.
3939
*
4040
* @param \Magento\Backend\Block\Template\Context $context
4141
* @param \Magento\Framework\Registry $registry
4242
* @param \Magento\Framework\Data\FormFactory $formFactory
43-
* @param \Magento\Core\Helper\Data $coreHelper
4443
* @param \Magento\Framework\Acl\RootResource $rootResource
4544
* @param \Magento\Framework\Acl\Resource\ProviderInterface $resourceProvider
4645
* @param \Magento\Integration\Helper\Data $integrationData
47-
* @param \Magento\Webapi\Helper\Data $webapiData
46+
* @param \Magento\Framework\Json\Encoder $encoder
47+
* @param \Magento\Integration\Service\V1\Integration $integrationService
4848
* @param array $data
4949
*/
5050
public function __construct(
5151
\Magento\Backend\Block\Template\Context $context,
5252
\Magento\Framework\Registry $registry,
5353
\Magento\Framework\Data\FormFactory $formFactory,
54-
\Magento\Core\Helper\Data $coreHelper,
5554
\Magento\Framework\Acl\RootResource $rootResource,
5655
\Magento\Framework\Acl\Resource\ProviderInterface $resourceProvider,
5756
\Magento\Integration\Helper\Data $integrationData,
58-
\Magento\Webapi\Helper\Data $webapiData,
57+
\Magento\Framework\Json\Encoder $encoder,
58+
\Magento\Integration\Service\V1\Integration $integrationService,
5959
array $data = []
6060
) {
6161
$this->_rootResource = $rootResource;
6262
$this->_resourceProvider = $resourceProvider;
6363
$this->_integrationData = $integrationData;
64-
$this->_webapiHelper = $webapiData;
65-
$this->_coreHelper = $coreHelper;
64+
$this->encoder = $encoder;
65+
$this->integrationService = $integrationService;
6666
parent::__construct($context, $registry, $formFactory, $data);
6767
}
6868

@@ -75,7 +75,17 @@ public function __construct(
7575
protected function _construct()
7676
{
7777
parent::_construct();
78-
$this->_selectedResources = $this->_webapiHelper->getSelectedResources();
78+
$integrationData = $this->_coreRegistry->registry(IntegrationController::REGISTRY_KEY_CURRENT_INTEGRATION);
79+
if (is_array($integrationData)
80+
&& isset($integrationData['integration_id'])
81+
&& $integrationData['integration_id']
82+
) {
83+
$this->_selectedResources = $this->integrationService->getSelectedResources(
84+
$integrationData['integration_id']
85+
);
86+
} else {
87+
$this->_selectedResources = [];
88+
}
7989
}
8090

8191
/**
@@ -133,7 +143,7 @@ public function getResourcesTreeJson()
133143
$resources = $this->_resourceProvider->getAclResources();
134144
$aclResourcesTree = $this->_integrationData->mapResources($resources[1]['children']);
135145

136-
return $this->_coreHelper->jsonEncode($aclResourcesTree);
146+
return $this->encoder->encode($aclResourcesTree);
137147
}
138148

139149
/**
@@ -150,7 +160,7 @@ public function getSelectedResourcesJson()
150160
$resources = $this->_resourceProvider->getAclResources();
151161
$selectedResources = $this->_getAllResourceIds($resources[1]['children']);
152162
}
153-
return $this->_coreHelper->jsonEncode($selectedResources);
163+
return $this->encoder->encode($selectedResources);
154164
}
155165

156166
/**

0 commit comments

Comments
 (0)