Skip to content

Commit 020f7d5

Browse files
authored
Merge pull request #36 from logeecom/dev
Release version 1.3.7
2 parents eca19eb + 46a05f6 commit 020f7d5

File tree

10 files changed

+91
-16
lines changed

10 files changed

+91
-16
lines changed

PacklinkPro/Block/Checkout/Config.php

Lines changed: 40 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,17 @@
1010
use Magento\Checkout\Model\Session;
1111
use Magento\Framework\Locale\Resolver;
1212
use Magento\Framework\View\Element\Template;
13+
use Magento\Framework\View\Element\Template\Context;
1314
use Magento\Quote\Model\Quote\Address;
1415
use Packlink\PacklinkPro\Bootstrap;
16+
use Packlink\PacklinkPro\Helper\CspNonceProviderFactory;
1517
use Packlink\PacklinkPro\IntegrationCore\BusinessLogic\Http\DTO\ParcelInfo;
1618
use Packlink\PacklinkPro\IntegrationCore\BusinessLogic\ShippingMethod\Interfaces\ShopShippingMethodService;
1719
use Packlink\PacklinkPro\IntegrationCore\BusinessLogic\ShippingMethod\ShippingMethodService;
1820
use Packlink\PacklinkPro\IntegrationCore\Infrastructure\ServiceRegister;
1921
use Packlink\PacklinkPro\Services\BusinessLogic\CarrierService;
2022
use Packlink\PacklinkPro\Services\BusinessLogic\ConfigurationService;
2123

22-
/**
23-
* Class Config.
24-
*
25-
* @package Packlink\PacklinkPro\Block\Checkout
26-
*/
2724
class Config extends Template
2825
{
2926
/**
@@ -40,25 +37,35 @@ class Config extends Template
4037
private $carrierService;
4138

4239
/**
43-
* Config constructor.
44-
*
45-
* @param \Magento\Framework\View\Element\Template\Context $context
46-
* @param \Magento\Checkout\Model\Session $session
47-
* @param \Magento\Framework\Locale\Resolver $locale
48-
* @param \Packlink\PacklinkPro\Bootstrap $bootstrap
40+
* @var Template\Context
41+
*/
42+
private $context;
43+
44+
45+
private $nonceProviderFactory;
46+
47+
/**
48+
* @param Context $context
49+
* @param Session $session
50+
* @param Resolver $locale
51+
* @param Bootstrap $bootstrap
52+
* @param CspNonceProviderFactory $nonceProviderFactory
4953
* @param array $data
5054
*/
5155
public function __construct(
5256
Template\Context $context,
5357
Session $session,
5458
Resolver $locale,
5559
Bootstrap $bootstrap,
60+
CspNonceProviderFactory $nonceProviderFactory,
5661
array $data = []
5762
) {
5863
parent::__construct($context, $data);
5964

6065
$this->checkoutSession = $session;
6166
$this->locale = $locale;
67+
$this->context = $context;
68+
$this->nonceProviderFactory = $nonceProviderFactory;
6269

6370
$bootstrap->initInstance();
6471
}
@@ -237,6 +244,28 @@ public function getCurrentLanguageCode()
237244
return $locale ? substr($locale, 0, 2) : 'en';
238245
}
239246

247+
/**
248+
* Csp nonce is necessary for Magento version 2.1.7 and higher.
249+
* Magento\Csp\Helper\CspNonceProvider class does not exist in earlier versions.
250+
*
251+
* @return string
252+
*
253+
* @throws \Magento\Framework\Exception\LocalizedException
254+
*/
255+
public function getCspNonce()
256+
{
257+
$cspNonceProvider = $this->nonceProviderFactory->create();
258+
259+
if ($cspNonceProvider) {
260+
return $cspNonceProvider->generateNonce();
261+
}
262+
263+
return '';
264+
}
265+
266+
/**
267+
* @return ShopShippingMethodService
268+
*/
240269
private function getCarrierService()
241270
{
242271
if ($this->carrierService === null) {
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
3+
namespace Packlink\PacklinkPro\Helper;
4+
5+
use Magento\Framework\ObjectManagerInterface;
6+
7+
/**
8+
* Class CspNonceProviderFactory.
9+
*
10+
* @package Packlink\PacklinkPro\Helper
11+
*/
12+
class CspNonceProviderFactory
13+
{
14+
/** @var ObjectManagerInterface */
15+
private $objectManager;
16+
17+
/**
18+
* @param ObjectManagerInterface $objectManager
19+
*/
20+
public function __construct(ObjectManagerInterface $objectManager)
21+
{
22+
$this->objectManager = $objectManager;
23+
}
24+
25+
/**
26+
* Create an instance of CspNonceProvider if it exists.
27+
*
28+
* @return object|null
29+
*/
30+
public function create()
31+
{
32+
if (class_exists('Magento\Csp\Helper\CspNonceProvider')) {
33+
return $this->objectManager->get('Magento\Csp\Helper\CspNonceProvider');
34+
}
35+
36+
return null;
37+
}
38+
}

PacklinkPro/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "packlink/magento2",
33
"description": "Save up to 70% on your shipping costs. No fixed fees, no minimum shipping volume required. Manage all your shipments in a single platform.",
44
"type": "magento2-module",
5-
"version": "1.3.6",
5+
"version": "1.3.7",
66
"license": [
77
"OSL-3.0",
88
"AFL-3.0"

PacklinkPro/etc/module.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@
88
-->
99
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
1010
xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
11-
<module name="Packlink_PacklinkPro" setup_version="1.3.6" schema_version="1.3.6"/>
11+
<module name="Packlink_PacklinkPro" setup_version="1.3.7" schema_version="1.3.7"/>
1212
</config>

PacklinkPro/view/frontend/templates/checkout/config.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989
<span hidden id="pl-change-drop-off-text"><?= __('Change drop-off location') ?></span>
9090

9191

92-
<script>
92+
<script nonce="<?= $block->getCspNonce() ?>">
9393
(function () {
9494
require(
9595
[

PacklinkPro/view/frontend/templates/checkout/shipping.phtml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,7 @@
8888
<span hidden id="pl-select-drop-off-text"><?= __('Select drop-off location') ?></span>
8989
<span hidden id="pl-change-drop-off-text"><?= __('Change drop-off location') ?></span>
9090

91-
92-
<script>
91+
<script nonce="<?= $block->getCspNonce() ?>">
9392
(function () {
9493
let logos = [],
9594
quoteItemWeights = <?= json_encode($block->getQuoteItemWeights()) ?>,
1.82 MB
Binary file not shown.

PluginInstallation/1.3.7/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
This folder contains packages for version 1.3.7.
2+
3+
Please follow instructions from [Readme file](../../Packlink/PacklinkPro/README.md).
4+
5+
Changes are described in the [Change log](../../CHANGELOG.md).
1.84 MB
Binary file not shown.

PluginInstallation/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file.
33

44
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
55

6+
## [1.3.7](https://github.com/packlink-dev/magento2_module/compare/v1.3.6...1.3.7)
7+
### Added
8+
- Compatibility with Magento 2.4.7
9+
610
## [1.3.6](https://github.com/packlink-dev/magento2_module/compare/v1.3.5...1.3.6)
711
### Changed
812
- Update core to the latest version

0 commit comments

Comments
 (0)