Skip to content

Commit 9afcd8c

Browse files
author
Sam Butler Thompson
authored
Merge pull request #120 from ctidigital/develop
3.1.2
2 parents 0399492 + 93efde0 commit 9afcd8c

16 files changed

+76
-3
lines changed

.travis.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ matrix:
2828

2929
before_install:
3030
- echo "{\"http-basic\":{\"repo.magento.com\":{\"username\":\"${MAGENTO_USERNAME}\",\"password\":\"${MAGENTO_PASSWORD}\"}}}" > auth.json
31-
- sh -c "if [ '$TEST_SUITE' = 'phpcs' ]; then composer require magento/framework:^102.0.3; fi"
32-
- sh -c "if [ '$TEST_SUITE' = 'unit' ]; then composer require magento/framework:^102.0.3; fi"
31+
- sh -c "if [ '$TEST_SUITE' = 'phpcs' ]; then composer require magento/framework:^103.0.1; fi"
32+
- sh -c "if [ '$TEST_SUITE' = 'unit' ]; then composer require magento/framework:^103.0.1; fi"
3333
- sh -c "if [ '$TEST_SUITE' = 'unit' ]; then composer require magento/module-catalog; fi"
3434
- sh -c "if [ '$TEST_SUITE' = 'unit' ]; then composer require magento/zendframework1; fi"
3535
install:

Component/AdminRoles.php

+3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
use Magento\Authorization\Model\UserContextInterface;
1010
use Magento\Authorization\Model\Acl\Role\Group as RoleGroup;
1111

12+
/**
13+
* @SuppressWarnings(PHPMD.ShortVariable)
14+
*/
1215
class AdminRoles implements ComponentInterface
1316
{
1417
protected $alias = 'adminroles';

Component/AdminUsers.php

+3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
use CtiDigital\Configurator\Api\LoggerInterface;
88
use CtiDigital\Configurator\Exception\ComponentException;
99

10+
/**
11+
* @SuppressWarnings(PHPMD.ShortVariable)
12+
*/
1013
class AdminUsers implements ComponentInterface
1114
{
1215
protected $alias = 'adminusers';

Component/ApiIntegrations.php

+3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
use Magento\Integration\Api\IntegrationServiceInterface;
1010
use CtiDigital\Configurator\Exception\ComponentException;
1111

12+
/**
13+
* @SuppressWarnings(PHPMD.ShortVariable)
14+
*/
1215
class ApiIntegrations implements ComponentInterface
1316
{
1417
protected $alias = 'apiintegrations';

Component/CatalogPriceRules/CatalogPriceRulesProcessor.php

+3
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
use Magento\CatalogRule\Model\Rule;
1515
use Magento\CatalogRule\Model\Rule\Job;
1616

17+
/**
18+
* @SuppressWarnings(PHPMD.ShortVariable)
19+
*/
1720
class CatalogPriceRulesProcessor implements ComponentProcessorInterface
1821
{
1922
/**

Component/Categories.php

+3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
use Magento\Store\Model\GroupFactory;
1010
use Magento\Framework\App\Filesystem\DirectoryList;
1111

12+
/**
13+
* @SuppressWarnings(PHPMD.ShortVariable)
14+
*/
1215
class Categories implements ComponentInterface
1316
{
1417
protected $alias = 'categories';

Component/Config.php

+34
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
class Config implements ComponentInterface
1818
{
1919
const PATH_THEME_ID = 'design/theme/theme_id';
20+
const ENCRYPTED_MODEL = \Magento\Config\Model\Config\Backend\Encrypted::class;
2021

2122
protected $alias = 'config';
2223
protected $name = 'Configuration';
@@ -57,16 +58,26 @@ class Config implements ComponentInterface
5758
*/
5859
private $log;
5960

61+
/**
62+
* @var ScopeConfig\Initial
63+
*/
64+
private $initialConfig;
65+
6066
/**
6167
* Config constructor.
6268
* @param ConfigResource $configResource
6369
* @param ScopeConfig $scopeConfig
70+
* @param ScopeConfig\Initial $initialConfig
6471
* @param CollectionFactory $collectionFactory
6572
* @param EncryptorInterface $encryptor
73+
* @param WebsiteFactory $websiteFactory
74+
* @param StoreFactory $storeFactory
75+
* @param LoggerInterface $log
6676
*/
6777
public function __construct(
6878
ConfigResource $configResource,
6979
ScopeConfig $scopeConfig,
80+
ScopeConfig\Initial $initialConfig,
7081
CollectionFactory $collectionFactory,
7182
EncryptorInterface $encryptor,
7283
WebsiteFactory $websiteFactory,
@@ -75,6 +86,7 @@ public function __construct(
7586
) {
7687
$this->configResource = $configResource;
7788
$this->scopeConfig = $scopeConfig;
89+
$this->initialConfig = $initialConfig;
7890
$this->collectionFactory = $collectionFactory;
7991
$this->encryptor = $encryptor;
8092
$this->websiteFactory = $websiteFactory;
@@ -98,12 +110,15 @@ public function execute($data = null) //phpcs:ignore Generic.Metrics.NestingLeve
98110
if ($scope == "global") {
99111
foreach ($configurations as $configuration) {
100112
// Handle encryption parameter
113+
101114
$encryption = 0;
102115
if (isset($configuration['encryption']) && $configuration['encryption'] == 1) {
103116
$encryption = 1;
104117
}
105118

106119
$convertedConfiguration = $this->convert($configuration);
120+
// Check if the path uses an encryption model. If yes, set encryption to true
121+
$encryption = $this->determineEncryption($convertedConfiguration, $encryption);
107122
$this->setGlobalConfig(
108123
$convertedConfiguration['path'],
109124
$convertedConfiguration['value'],
@@ -121,6 +136,8 @@ public function execute($data = null) //phpcs:ignore Generic.Metrics.NestingLeve
121136
$encryption = 1;
122137
}
123138
$convertedConfiguration = $this->convert($configuration);
139+
// Check if the path uses an encryption model. If yes, set encryption to true
140+
$encryption = $this->determineEncryption($convertedConfiguration, $encryption);
124141
$this->setWebsiteConfig(
125142
$convertedConfiguration['path'],
126143
$convertedConfiguration['value'],
@@ -141,6 +158,8 @@ public function execute($data = null) //phpcs:ignore Generic.Metrics.NestingLeve
141158
}
142159

143160
$convertedConfiguration = $this->convert($configuration);
161+
// Check if the path uses an encryption model. If yes, set encryption to true
162+
$encryption = $this->determineEncryption($convertedConfiguration, $encryption);
144163
$this->setStoreConfig(
145164
$convertedConfiguration['path'],
146165
$convertedConfiguration['value'],
@@ -156,6 +175,21 @@ public function execute($data = null) //phpcs:ignore Generic.Metrics.NestingLeve
156175
}
157176
}
158177

178+
private function determineEncryption(array $configuration, $encryption)
179+
{
180+
$metaData = $this->initialConfig->getMetadata();
181+
182+
foreach ($metaData as $path => $processor) {
183+
if ($path == $configuration['path']) {
184+
if (isset($processor['backendModel']) && $processor['backendModel'] === self::ENCRYPTED_MODEL) {
185+
$encryption = 1;
186+
}
187+
}
188+
}
189+
190+
return $encryption;
191+
}
192+
159193
private function setGlobalConfig($path, $value, $encrypted = 0)
160194
{
161195
try {

Component/CustomerGroups.php

+3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
use CtiDigital\Configurator\Exception\ComponentException;
88
use CtiDigital\Configurator\Api\LoggerInterface;
99

10+
/**
11+
* @SuppressWarnings(PHPMD.ShortVariable)
12+
*/
1013
class CustomerGroups implements ComponentInterface
1114
{
1215
protected $alias = 'customergroups';

Component/Product/AttributeOption.php

+3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
use Magento\Catalog\Model\Product;
1111
use CtiDigital\Configurator\Api\LoggerInterface;
1212

13+
/**
14+
* @SuppressWarnings(PHPMD.ShortVariable)
15+
*/
1316
class AttributeOption
1417
{
1518
/**

Component/Products.php

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
/**
1313
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
1414
* @SuppressWarnings(PHPMD.ExcessiveClassComplexity)
15+
* @SuppressWarnings(PHPMD.ShortVariable)
1516
*/
1617
class Products implements ComponentInterface
1718
{

Component/ReviewRating.php

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
/**
1515
* @SuppressWarnings("CouplingBetweenObjects")
16+
* @SuppressWarnings(PHPMD.ShortVariable)
1617
*/
1718
class ReviewRating implements ComponentInterface
1819
{

Component/Rewrites.php

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
use Magento\UrlRewrite\Model\UrlRewriteFactory;
99
use Magento\UrlRewrite\Model\UrlPersistInterface;
1010

11+
/**
12+
* @SuppressWarnings(PHPMD.ShortVariable)
13+
*/
1114
class Rewrites implements ComponentInterface
1215
{
1316
protected $alias = "rewrites";

Component/TaxRules.php

+3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
use Magento\Tax\Model\Calculation\RateFactory;
1010
use Magento\Tax\Model\ClassModelFactory;
1111

12+
/**
13+
* @SuppressWarnings(PHPMD.ShortVariable)
14+
*/
1215
class TaxRules implements ComponentInterface
1316
{
1417
protected $alias = 'taxrules';

Model/Processor.php

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
* Class Processor - The overarching class that reads and processes the configurator files.
1717
*
1818
* @SuppressWarnings(PHPMD.ExcessiveClassComplexity)
19+
* @SuppressWarnings(PHPMD.ShortVariable)
1920
*/
2021
class Processor
2122
{

Test/Unit/Component/ConfigTest.php

+9
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ class ConfigTest extends \PHPUnit\Framework\TestCase
2929
*/
3030
private $scopeConfig;
3131

32+
/**
33+
* @var ScopeConfig\Initial|\PHPUnit\Framework\MockObject\MockObject
34+
*/
35+
private $initialConfig;
36+
3237
/**
3338
* @var Collection|\PHPUnit\Framework\MockObject\MockObject
3439
*/
@@ -67,6 +72,9 @@ protected function setUp()
6772
$this->scopeConfig = $this->getMockBuilder(ScopeConfig::class)
6873
->disableOriginalConstructor()
6974
->getMock();
75+
$this->initialConfig = $this->getMockBuilder(ScopeConfig\Initial::class)
76+
->disableOriginalConstructor()
77+
->getMock();
7078
$this->collection = $this->getMockBuilder(Collection::class)
7179
->disableOriginalConstructor()
7280
->getMock();
@@ -90,6 +98,7 @@ protected function setUp()
9098
$this->config = new Config(
9199
$this->configResource,
92100
$this->scopeConfig,
101+
$this->initialConfig,
93102
$this->collectionFactory,
94103
$this->encryptorInterface,
95104
$this->websiteFactory,

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"phpunit/phpunit": "^6.2",
2121
"magento/magento-coding-standard": "5"
2222
},
23-
"version": "3.1.1",
23+
"version": "3.1.2",
2424
"autoload": {
2525
"files": [ "registration.php" ],
2626
"psr-4": {

0 commit comments

Comments
 (0)