Skip to content

Commit b1bc6a3

Browse files
author
Igor Melnikov
committed
MAGETWO-62134: Create data converter that can process nested serialized data
Resolving code review feedback
1 parent e6225cc commit b1bc6a3

File tree

4 files changed

+27
-39
lines changed

4 files changed

+27
-39
lines changed

app/code/Magento/Bundle/Model/Sales/Order/Pdf/Items/AbstractItems.php

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
use Magento\Framework\Serialize\Serializer\Json;
1010

1111
/**
12-
* Sales Order Pdf Items renderer
12+
* Order pdf items renderer
13+
*
1314
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
1415
*/
1516
abstract class AbstractItems extends \Magento\Sales\Model\Order\Pdf\Items\AbstractItems
@@ -22,10 +23,12 @@ abstract class AbstractItems extends \Magento\Sales\Model\Order\Pdf\Items\Abstra
2223
private $serializer;
2324

2425
/**
26+
* Constructor
27+
*
2528
* @param \Magento\Framework\Model\Context $context
2629
* @param \Magento\Framework\Registry $registry
2730
* @param \Magento\Tax\Helper\Data $taxData
28-
* @param \Magento\Framework\Filesystem $filesystem ,
31+
* @param \Magento\Framework\Filesystem $filesystem
2932
* @param \Magento\Framework\Filter\FilterManager $filterManager
3033
* @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource
3134
* @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection
@@ -43,8 +46,7 @@ public function __construct(
4346
array $data = [],
4447
Json $serializer = null
4548
) {
46-
$this->serializer = $serializer;
47-
49+
$this->serializer = $serializer ?: \Magento\Framework\App\ObjectManager::getInstance()->get(Json::class);
4850
parent::__construct(
4951
$context,
5052
$registry,
@@ -202,7 +204,7 @@ public function getSelectionAttributes($item)
202204
$options = $item->getOrderItem()->getProductOptions();
203205
}
204206
if (isset($options['bundle_selection_attributes'])) {
205-
return $this->getSerializer()->unserialize($options['bundle_selection_attributes']);
207+
return $this->serializer->unserialize($options['bundle_selection_attributes']);
206208
}
207209
return null;
208210
}
@@ -287,19 +289,4 @@ public function canShowPriceInfo($item)
287289
}
288290
return false;
289291
}
290-
291-
/**
292-
* The getter function to get serializer
293-
*
294-
* @return Json
295-
*
296-
* @deprecated
297-
*/
298-
private function getSerializer()
299-
{
300-
if ($this->serializer === null) {
301-
$this->serializer = \Magento\Framework\App\ObjectManager::getInstance()->get(Json::class);
302-
}
303-
return $this->serializer;
304-
}
305292
}

app/code/Magento/Catalog/Test/Unit/Helper/Product/ConfigurationTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
class ConfigurationTest extends \PHPUnit_Framework_TestCase
99
{
1010
/**
11-
* @var \Magento\Framework\Serialize\Serializer\Json | \PHPUnit_Framework_MockObject_MockObject
11+
* @var \Magento\Framework\Serialize\Serializer\Json|\PHPUnit_Framework_MockObject_MockObject
1212
*/
1313
protected $serializer;
1414

app/code/Magento/Quote/Model/Quote/Address/Total.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ class Total extends \Magento\Framework\DataObject
2525
private $serializer;
2626

2727
/**
28-
* @param array $data [optional]
28+
* Constructor
29+
*
30+
* @param array $data
2931
* @param \Magento\Framework\Serialize\Serializer\Json|null $serializer
3032
*/
3133
public function __construct(

app/code/Magento/Tax/Helper/Data.php

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33
* Copyright © 2016 Magento. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6-
7-
// @codingStandardsIgnoreFile
8-
96
namespace Magento\Tax\Helper;
107

118
use Magento\Framework\Pricing\PriceCurrencyInterface;
@@ -22,9 +19,11 @@
2219
use Magento\Framework\App\ObjectManager;
2320

2421
/**
25-
* Catalog data helper
22+
* Tax helper
23+
*
2624
* @SuppressWarnings(PHPMD.TooManyFields)
2725
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
26+
* @codingStandardsIgnoreFile
2827
*/
2928
class Data extends \Magento\Framework\App\Helper\AbstractHelper
3029
{
@@ -80,9 +79,7 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper
8079
protected $_localeResolver;
8180

8281
/**
83-
* \Magento\Catalog\Helper\Data
84-
*
85-
* @var CatalogHelper
82+
* @var \Magento\Catalog\Helper\Data
8683
*/
8784
protected $catalogHelper;
8885

@@ -102,17 +99,19 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper
10299
private $serializer;
103100

104101
/**
105-
* @param \Magento\Framework\App\Helper\Context $context
106-
* @param \Magento\Framework\Json\Helper\Data $jsonHelper
107-
* @param Config $taxConfig
108-
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
109-
* @param \Magento\Framework\Locale\FormatInterface $localeFormat
102+
* Constructor
103+
*
104+
* @param \Magento\Framework\App\Helper\Context $context
105+
* @param \Magento\Framework\Json\Helper\Data $jsonHelper
106+
* @param Config $taxConfig
107+
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
108+
* @param \Magento\Framework\Locale\FormatInterface $localeFormat
110109
* @param \Magento\Tax\Model\ResourceModel\Sales\Order\Tax\CollectionFactory $orderTaxCollectionFactory
111-
* @param \Magento\Framework\Locale\ResolverInterface $localeResolver
112-
* @param \Magento\Catalog\Helper\Data $catalogHelper
113-
* @param OrderTaxManagementInterface $orderTaxManagement
114-
* @param PriceCurrencyInterface $priceCurrency
115-
* @param Json $serializer
110+
* @param \Magento\Framework\Locale\ResolverInterface $localeResolver
111+
* @param \Magento\Catalog\Helper\Data $catalogHelper
112+
* @param OrderTaxManagementInterface $orderTaxManagement
113+
* @param PriceCurrencyInterface $priceCurrency
114+
* @param Json $serializer
116115
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
117116
*/
118117
public function __construct(

0 commit comments

Comments
 (0)