Skip to content
This repository has been archived by the owner on Jun 10, 2020. It is now read-only.

Commit

Permalink
Extended retro-compatibility from version 2.1.17
Browse files Browse the repository at this point in the history
  • Loading branch information
ildelux committed Apr 1, 2019
1 parent 7b4e5cf commit 4a1692f
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 50 deletions.
2 changes: 1 addition & 1 deletion Block/Adminhtml/Checks.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Checks extends Template
const STATUS_OK = 3;

const PHP_MIN_VERSION = '7.0';
const MAGENTO_MIN_VERSION = '2.2.3';
const MAGENTO_MIN_VERSION = '2.1.17';
const HUB_LATEST_VERSION_FILE = 'https://raw.githubusercontent.com/contactlab/magento2-hub/master/etc/module.xml';

protected $_moduleResource;
Expand Down
17 changes: 6 additions & 11 deletions Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
use Magento\Catalog\Helper\Image as ImageHelper;
use Magento\Framework\UrlInterface;
use Magento\Catalog\Api\CategoryRepositoryInterface;
use Magento\Framework\Serialize\Serializer\Json;


class Data extends AbstractHelper
Expand Down Expand Up @@ -64,7 +63,6 @@ class Data extends AbstractHelper
protected $_imageHelper;
protected $_urlBuilder;
protected $_categoryRepository;
protected $_serializer;


public function __construct(
Expand All @@ -77,8 +75,7 @@ public function __construct(
Address $address,
ImageHelper $imageHelper,
UrlInterface $urlBuilder,
CategoryRepositoryInterface $categoryRepository,
Json $serializer = null
CategoryRepositoryInterface $categoryRepository

) {
$this->_resourceConfig = $resourceConfig;
Expand All @@ -90,8 +87,6 @@ public function __construct(
$this->_imageHelper = $imageHelper;
$this->_urlBuilder = $urlBuilder;
$this->_categoryRepository = $categoryRepository;
$this->_serializer = $serializer ?: \Magento\Framework\App\ObjectManager::getInstance()
->get(Json::class);
parent::__construct($context);

}
Expand All @@ -107,7 +102,7 @@ public function log($text)
}
return $this;
}

protected function _isLogEnabled($storeId = null)
{
return (bool)$this->scopeConfig->getValue(self::CONTACTLAB_HUB_LOG_ENABLED,
Expand Down Expand Up @@ -233,7 +228,7 @@ public function getRemoteIpAddress($customerId = null)


}

public function sendAbandonedCartToNotSubscribed($storeId = null)
{
return (bool)$this->scopeConfig->getValue(self::CONTACTLAB_HUB_ABANDONED_CART_TO_NOT_SUBSCRIBED,
Expand Down Expand Up @@ -394,11 +389,11 @@ public function getExternalId($customer)
public function getCustomerExtraProperties($customer, $type = 'extended')
{
$extraProperties = array();
$attributesMap = $this->_serializer->unserialize($this->scopeConfig->getValue(
$attributesMap = json_decode($this->scopeConfig->getValue(
self::CONTACTLAB_HUB_CUSTOMER_EXTRA_PROPERTIES_ATTRIBUTE_MAP,
ScopeInterface::SCOPE_STORE,
$customer->getStoreId()
));
), true);
foreach ($attributesMap as $map)
{
if($type == $map['hub_type'])
Expand Down Expand Up @@ -499,7 +494,7 @@ public function getObjProduct($product)
if($product->getImage())
{
$productImage = $this->_urlBuilder->getBaseUrl(['_type' => UrlInterface::URL_TYPE_MEDIA])
. 'catalog/product' . $product->getImage();
. 'catalog/product' . $product->getImage();
}
else
{
Expand Down
39 changes: 3 additions & 36 deletions Model/Adminhtml/System/Config/Backend/Map/Customer.php
Original file line number Diff line number Diff line change
@@ -1,27 +1,4 @@
<?php
/*
namespace Contactlab\Hub\Model\Adminhtml\System\Config\Backend\Map;
class Customer extends \Magento\Config\Model\Config\Backend\Serialized
{
const XML_PATH_HUB_FIELD_ATTRIBUTE = 'customer_mapping';
public function beforeSave()
{
$_value = $this->getValue();
unset($_value[static::XML_PATH_HUB_FIELD_ATTRIBUTE][-1]);
$startOne = array_combine(range(1, count($_value[static::XML_PATH_HUB_FIELD_ATTRIBUTE])),
array_values($_value[static::XML_PATH_HUB_FIELD_ATTRIBUTE]));
$_value[static::XML_PATH_HUB_FIELD_ATTRIBUTE] = $startOne;
$this->setValue($_value);
parent::beforeSave();
}
}
*/


namespace Contactlab\Hub\Model\Adminhtml\System\Config\Backend\Map;

Expand All @@ -33,7 +10,6 @@ public function beforeSave()
use Magento\Framework\Model\Context;
use Magento\Framework\Model\ResourceModel\AbstractResource;
use Magento\Framework\Registry;
use Magento\Framework\Serialize\Serializer\Json;

/**
* Class CountryCreditCard
Expand All @@ -45,11 +21,6 @@ class Customer extends Value
*/
protected $mathRandom;

/**
* @var \Magento\Framework\Serialize\Serializer\Json
*/
private $serializer;

/**
* @param \Magento\Framework\Model\Context $context
* @param \Magento\Framework\Registry $registry
Expand All @@ -59,7 +30,6 @@ class Customer extends Value
* @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource
* @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection
* @param array $data
* @param \Magento\Framework\Serialize\Serializer\Json $serializer
*/
public function __construct(
Context $context,
Expand All @@ -69,12 +39,9 @@ public function __construct(
Random $mathRandom,
AbstractResource $resource = null,
AbstractDb $resourceCollection = null,
array $data = [],
Json $serializer = null
array $data = []
) {
$this->mathRandom = $mathRandom;
$this->serializer = $serializer ?: \Magento\Framework\App\ObjectManager::getInstance()
->get(Json::class);
parent::__construct($context, $registry, $config, $cacheTypeList, $resource, $resourceCollection, $data);
}

Expand All @@ -90,7 +57,7 @@ public function beforeSave()
{
unset($value['__empty']);
}
$this->setValue($this->serializer->serialize($value));
$this->setValue(json_encode($value));
return $this;
}

Expand All @@ -102,7 +69,7 @@ public function beforeSave()
public function afterLoad()
{
if ($this->getValue()) {
$value = $this->serializer->unserialize($this->getValue());
$value = json_decode($this->getValue(), true);
if (is_array($value)) {
$this->setValue($value);
}
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

},
"type": "magento2-module",
"version": "1.6.0",
"version": "1.7.0",
"license": [
"OSL-3.0",
"AFL-3.0"
Expand Down
2 changes: 1 addition & 1 deletion etc/module.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Contactlab_Hub" setup_version="1.6.0">
<module name="Contactlab_Hub" setup_version="1.7.0">
<sequence>
<module name="Contactlab_Core"/>
</sequence>
Expand Down

0 comments on commit 4a1692f

Please sign in to comment.