Skip to content
This repository was archived by the owner on Jan 6, 2022. It is now read-only.

Commit f1ef312

Browse files
committed
Merge branch 'release/0.4.0'
2 parents e01d797 + 0295add commit f1ef312

File tree

6 files changed

+47
-8
lines changed

6 files changed

+47
-8
lines changed

README.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,14 @@ For example:
2222
dev/debug/template_hints: 1
2323
stores-1:
2424
currency/options/base: GBP
25+
dev/restrict/allow_ips: null
2526

26-
The above will disable template hints on product, enable template hints on the development environment and set the currency to Pounds Sterling in the store scope for the store with ID #1.
27+
The above will:
28+
29+
* disable template hints on product;
30+
* enable template hints on the development environment;
31+
* set the currency to Pounds Sterling in the store scope for the store with ID #1;
32+
* ensure the allowed development ip's are inherited from the website for store #1.
2733

2834
Valid scope keys are:
2935

src/MageConfigSync/Application.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class Application extends \Symfony\Component\Console\Application
1010
{
1111
public function __construct()
1212
{
13-
parent::__construct("mageconfigsync", "0.3.1");
13+
parent::__construct("mageconfigsync", "0.4.0");
1414

1515
$this->add(new DumpCommand());
1616
$this->add(new DiffCommand());

src/MageConfigSync/Command/DiffCommand.php

+12-3
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,11 @@ protected function execute(InputInterface $input, OutputInterface $output)
7575
foreach ($scope_data as $key => $value) {
7676
$diff_count++;
7777
$diff_message = sprintf(
78-
"%s/%s is different (File: '%s', DB: '%s')",
78+
"%s/%s is different (File: %s, DB: %s)",
7979
$scope,
8080
$key,
81-
$file_data[$scope][$key],
82-
$db_data[$scope][$key]
81+
$this->decorateValue($file_data[$scope][$key]),
82+
$this->decorateValue($db_data[$scope][$key])
8383
);
8484
$output->writeln($diff_message);
8585
}
@@ -91,4 +91,13 @@ protected function execute(InputInterface $input, OutputInterface $output)
9191
}
9292
}
9393
}
94+
95+
protected function decorateValue($value)
96+
{
97+
if (is_null($value)) {
98+
return 'null';
99+
} else {
100+
return "'{$value}'";
101+
}
102+
}
94103
}

src/MageConfigSync/Command/LoadCommand.php

+6-2
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,18 @@ protected function execute(InputInterface $input, OutputInterface $output)
6767
foreach ($scope_data as $path => $value) {
6868
$scope_data = ConfigYaml::extractFromScopeKey($scope_key);
6969

70-
$affected_rows = $config_adapter->setValue($path, $value, $scope_data['scope'], $scope_data['scope_id']);
70+
if ($value !== null) {
71+
$affected_rows = $config_adapter->setValue($path, $value, $scope_data['scope'], $scope_data['scope_id']);
72+
} else {
73+
$affected_rows = $config_adapter->deleteValue($path, $scope_data['scope'], $scope_data['scope_id']);
74+
}
7175

7276
if ($affected_rows > 0) {
7377
$line = sprintf(
7478
"[%s] %s -> %s",
7579
$scope_key,
7680
$path,
77-
$value
81+
$value ?: 'null'
7882
);
7983

8084
if (method_exists($output, 'getErrorOutput')) {

src/MageConfigSync/Magento/ConfigurationAdapter.php

+20
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,26 @@ public function setValue($path, $value, $scope, $scope_id)
4343
);
4444
}
4545

46+
/**
47+
* @param $path
48+
* @param $scope
49+
* @param $scope_id
50+
*
51+
* @return int Number of affected rows
52+
*/
53+
public function deleteValue($path, $scope, $scope_id)
54+
{
55+
$write = $this->_magento->getDatabaseWriteConnection();
56+
return $write->delete(
57+
$this->_table_name,
58+
array(
59+
'scope = ?' => $scope,
60+
'scope_id = ?' => $scope_id,
61+
'path = ?' => $path
62+
)
63+
);
64+
}
65+
4666
/**
4767
* @param $path
4868
* @return array
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<?php /* This file is deliberatly empty. */
1+
<?php /* This file is deliberately empty. */

0 commit comments

Comments
 (0)