Skip to content

Commit

Permalink
3.4.0: Magento 2 validation fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Ébano Penha Andrello Lopes committed Jul 18, 2019
1 parent 3c960cd commit bff0cce
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 12 deletions.
29 changes: 24 additions & 5 deletions Helper/FulfillmentHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Signifyd\Connect\Logger\Logger;
use Signifyd\Core\SignifydModel;
use Magento\Sales\Model\ResourceModel\Order as OrderResourceModel;
use Magento\Framework\Serialize\SerializerInterface;

class FulfillmentHelper
{
Expand Down Expand Up @@ -48,14 +49,31 @@ class FulfillmentHelper
*/
protected $configHelper;

/**
* @var SerializerInterface
*/
protected $serializer;

/**
* FulfillmentHelper constructor.
* @param CasedataFactory $casedataFactory
* @param FulfillmentFactory $fulfillmentFactory
* @param CasedataResourceModel $casedataResourceModel
* @param FulfillmentResourceModel $fulfillmentResourceModel
* @param OrderResourceModel $orderResourceModel
* @param Logger $logger
* @param ConfigHelper $configHelper
* @param SerializerInterface $serializer
*/
public function __construct(
CasedataFactory $casedataFactory,
FulfillmentFactory $fulfillmentFactory,
CasedataResourceModel $casedataResourceModel,
FulfillmentResourceModel $fulfillmentResourceModel,
OrderResourceModel $orderResourceModel,
Logger $logger,
ConfigHelper $configHelper
ConfigHelper $configHelper,
SerializerInterface $serializer
) {
$this->casedataFactory = $casedataFactory;
$this->fulfillmentFactory = $fulfillmentFactory;
Expand All @@ -66,6 +84,7 @@ public function __construct(

$this->logger = $logger;
$this->configHelper = $configHelper;
$this->serializer = $serializer;
}

public function postFulfillmentToSignifyd(\Magento\Sales\Model\Order\Shipment $shipment)
Expand Down Expand Up @@ -156,11 +175,11 @@ public function prepareFulfillmentToDatabase(\Signifyd\Models\Fulfillment $fulfi
$fulfillment->setData('created_at', $fulfillmentData->createdAt);
$fulfillment->setData('delivery_email', $fulfillmentData->deliveryEmail);
$fulfillment->setData('fulfillment_status', $fulfillmentData->fulfillmentStatus);
$fulfillment->setData('tracking_numbers', serialize($fulfillmentData->trackingNumbers));
$fulfillment->setData('tracking_urls', serialize($fulfillmentData->trackingUrls));
$fulfillment->setData('products', serialize($fulfillmentData->products));
$fulfillment->setData('tracking_numbers', $this->serializer->serialize($fulfillmentData->trackingNumbers));
$fulfillment->setData('tracking_urls', $this->serializer->serialize($fulfillmentData->trackingUrls));
$fulfillment->setData('products', $this->serializer->serialize($fulfillmentData->products));
$fulfillment->setData('shipment_status', $fulfillmentData->shipmentStatus);
$fulfillment->setData('delivery_address', serialize($fulfillmentData->deliveryAddress));
$fulfillment->setData('delivery_address', $this->serializer->serialize($fulfillmentData->deliveryAddress));
$fulfillment->setData('recipient_name', $fulfillmentData->recipientName);
$fulfillment->setData('confirmation_name', $fulfillmentData->confirmationName);
$fulfillment->setData('confirmation_phone', $fulfillmentData->confirmationPhone);
Expand Down
15 changes: 12 additions & 3 deletions Model/Casedata.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Magento\Framework\ObjectManagerInterface;
use Magento\Sales\Model\Order;
use Signifyd\Connect\Logger\Logger;
use Magento\Framework\Serialize\SerializerInterface;

/**
* ORM model declaration for case data
Expand Down Expand Up @@ -67,13 +68,19 @@ class Casedata extends AbstractModel
*/
protected $logger;

/**
* @var SerializerInterface
*/
protected $serializer;

/**
* Casedata constructor.
* @param Context $context
* @param Registry $registry
* @param \Signifyd\Connect\Helper\ConfigHelper $configHelper
* @param InvoiceService $invoiceService
* @param Logger
* @param SerializerInterface $serializer
*/
public function __construct(
Context $context,
Expand All @@ -83,7 +90,8 @@ public function __construct(
InvoiceSender $invoiceSender,
ObjectManagerInterface $objectManager,
\Magento\Sales\Model\OrderFactory $orderFactory,
Logger $logger
Logger $logger,
SerializerInterface $serializer
)
{
$this->configHelper = $configHelper;
Expand All @@ -92,6 +100,7 @@ public function __construct(
$this->objectManager = $objectManager;
$this->orderFactory = $orderFactory;
$this->logger = $logger;
$this->serializer = $serializer;

parent::__construct($context, $registry);
}
Expand Down Expand Up @@ -516,7 +525,7 @@ public function getEntries($index = null)
$entries = $this->getData('entries_text');

if (!empty($entries)) {
@$entries = unserialize($entries);
$entries = $this->serializer->unserialize($entries);
}

if (!is_array($entries)) {
Expand All @@ -539,7 +548,7 @@ public function setEntries($index, $value = null)
$entries[$index] = $value;
}

@$entries = serialize($entries);
$entries = $this->serializer->serialize($entries);
$this->setData('entries_text', $entries);

return $this;
Expand Down
2 changes: 1 addition & 1 deletion Model/Message/BuiltinConflict.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public function isDisplayed()
*/
public function getIdentity()
{
return md5('SIGNIFYD_CONNECT_BUILTIN_CONFLICT');
return sha1('SIGNIFYD_CONNECT_BUILTIN_CONFLICT');
}
/**
* Retrieve message text
Expand Down
4 changes: 2 additions & 2 deletions Model/Payment/DataMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public function checkMethod(\Magento\Sales\Api\Data\OrderPaymentInterface $order
* @param \Magento\Sales\Model\Order $order
* @return string
*/
final public function getCode(\Magento\Sales\Model\Order $order)
public function getCode(\Magento\Sales\Model\Order $order)
{
if ($this->getDataCalled) {
return null;
Expand All @@ -103,7 +103,7 @@ final public function getCode(\Magento\Sales\Model\Order $order)
* @param \Magento\Sales\Model\Order $order
* @return string
*/
final public function getData(\Magento\Sales\Model\Order $order)
public function getData(\Magento\Sales\Model\Order $order)
{
$this->checkMethod($order->getPayment());
return $this->getPaymentData($order);
Expand Down
11 changes: 10 additions & 1 deletion Ui/Component/Listing/Columns/CaseLink.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Magento\Framework\View\Element\UiComponent\ContextInterface;
use Magento\Framework\View\Element\UiComponentFactory;
use Magento\Ui\Component\Listing\Columns\Column;
use Magento\Framework\Serialize\SerializerInterface;

/**
* Class CaseLink
Expand All @@ -20,22 +21,30 @@ class CaseLink extends Column
*/
protected $objectManager;

/**
* @var SerializerInterface
*/
protected $serializer;

/**
* CaseLink constructor.
* @param ContextInterface $context
* @param UiComponentFactory $uiComponentFactory
* @param ObjectManagerInterface $objectManager
* @param SerializerInterface $serializer
* @param array $components
* @param array $data
*/
public function __construct(
ContextInterface $context,
UiComponentFactory $uiComponentFactory,
ObjectManagerInterface $objectManager,
SerializerInterface $serializer,
array $components = [],
array $data = []
) {
$this->objectManager = $objectManager;
$this->serializer = $serializer;
parent::__construct($context, $uiComponentFactory, $components, $data);
}

Expand All @@ -59,7 +68,7 @@ public function prepareDataSource(array $dataSource)
$entries = $case->getEntriesText();

if (!empty($entries)) {
@$entries = unserialize($entries);
$entries = $this->serializer->unserialize($entries);
if (is_array($entries) && isset($entries['testInvestigation']) && $entries['testInvestigation'] == true) {
$item[$name] = "TEST: {$item[$name]}";
}
Expand Down

0 comments on commit bff0cce

Please sign in to comment.