Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace native serialize function with abstract serializer #24

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper
*/
protected $_priceHelper;

/**
* @var \Magento\Framework\Serialize\SerializerInterface
*/
private $_serializer;

/**
* Constructor
*
Expand All @@ -41,9 +46,11 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper
*/
public function __construct(
\Magento\Framework\App\Helper\Context $context,
\Magento\Framework\Pricing\Helper\Data $priceHelper
\Magento\Framework\Pricing\Helper\Data $priceHelper,
\Magento\Framework\Serialize\SerializerInterface $serializer
){
$this->_priceHelper = $priceHelper;
$this->_serializer = $serializer;
parent::__construct($context);
}

Expand All @@ -58,7 +65,7 @@ public function getConversion($product)
$productUnit = $product->getData('baseprice_product_unit');
$referenceUnit = $product->getData('baseprice_reference_unit');

$configArray = unserialize($this->scopeConfig->getValue(
$configArray = $this->_serializer->unserialize($this->scopeConfig->getValue(
self::CONVERSION_CONFIG_PATH,
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
));
Expand Down
11 changes: 9 additions & 2 deletions Setup/InstallData.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ class InstallData implements InstallDataInterface
*/
protected $_eavConfig;

/**
* @var \Magento\Framework\Serialize\SerializerInterface
*/
private $_serializer;

/**
* Constructor
*
Expand All @@ -60,12 +65,14 @@ public function __construct(
\Magento\Eav\Setup\EavSetupFactory $eavSetupFactory,
\Magento\Catalog\Api\ProductAttributeOptionManagementInterface $productAttributeOptionManagementInterface,
\Magento\Config\Model\ResourceModel\Config $configResource,
\Magento\Eav\Model\Config $eavConfig
\Magento\Eav\Model\Config $eavConfig,
\Magento\Framework\Serialize\SerializerInterface $serializer
){
$this->_eavSetupFactory = $eavSetupFactory;
$this->_productAttributeOptionManagementInterface = $productAttributeOptionManagementInterface;
$this->_configResource = $configResource;
$this->_eavConfig = $eavConfig;
$this->_serializer = $serializer;
}

/**
Expand Down Expand Up @@ -268,7 +275,7 @@ protected function _setSystemConfiguration()
// save system configuration
$this->_configResource->saveConfig(
\Magenerds\BasePrice\Helper\Data::CONVERSION_CONFIG_PATH,
serialize($data),
$this->_serializer->serialize($data),
\Magento\Framework\App\Config\ScopeConfigInterface::SCOPE_TYPE_DEFAULT,
0
);
Expand Down