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

Commit

Permalink
Merge branch 'release/0.4.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
punkstar committed Sep 22, 2015
2 parents e01d797 + 0295add commit f1ef312
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 8 deletions.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,14 @@ For example:
dev/debug/template_hints: 1
stores-1:
currency/options/base: GBP
dev/restrict/allow_ips: null

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.
The above will:

* disable template hints on product;
* enable template hints on the development environment;
* set the currency to Pounds Sterling in the store scope for the store with ID #1;
* ensure the allowed development ip's are inherited from the website for store #1.

Valid scope keys are:

Expand Down
2 changes: 1 addition & 1 deletion src/MageConfigSync/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Application extends \Symfony\Component\Console\Application
{
public function __construct()
{
parent::__construct("mageconfigsync", "0.3.1");
parent::__construct("mageconfigsync", "0.4.0");

$this->add(new DumpCommand());
$this->add(new DiffCommand());
Expand Down
15 changes: 12 additions & 3 deletions src/MageConfigSync/Command/DiffCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,11 @@ protected function execute(InputInterface $input, OutputInterface $output)
foreach ($scope_data as $key => $value) {
$diff_count++;
$diff_message = sprintf(
"%s/%s is different (File: '%s', DB: '%s')",
"%s/%s is different (File: %s, DB: %s)",
$scope,
$key,
$file_data[$scope][$key],
$db_data[$scope][$key]
$this->decorateValue($file_data[$scope][$key]),
$this->decorateValue($db_data[$scope][$key])
);
$output->writeln($diff_message);
}
Expand All @@ -91,4 +91,13 @@ protected function execute(InputInterface $input, OutputInterface $output)
}
}
}

protected function decorateValue($value)
{
if (is_null($value)) {
return 'null';
} else {
return "'{$value}'";
}
}
}
8 changes: 6 additions & 2 deletions src/MageConfigSync/Command/LoadCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,18 @@ protected function execute(InputInterface $input, OutputInterface $output)
foreach ($scope_data as $path => $value) {
$scope_data = ConfigYaml::extractFromScopeKey($scope_key);

$affected_rows = $config_adapter->setValue($path, $value, $scope_data['scope'], $scope_data['scope_id']);
if ($value !== null) {
$affected_rows = $config_adapter->setValue($path, $value, $scope_data['scope'], $scope_data['scope_id']);
} else {
$affected_rows = $config_adapter->deleteValue($path, $scope_data['scope'], $scope_data['scope_id']);
}

if ($affected_rows > 0) {
$line = sprintf(
"[%s] %s -> %s",
$scope_key,
$path,
$value
$value ?: 'null'
);

if (method_exists($output, 'getErrorOutput')) {
Expand Down
20 changes: 20 additions & 0 deletions src/MageConfigSync/Magento/ConfigurationAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,26 @@ public function setValue($path, $value, $scope, $scope_id)
);
}

/**
* @param $path
* @param $scope
* @param $scope_id
*
* @return int Number of affected rows
*/
public function deleteValue($path, $scope, $scope_id)
{
$write = $this->_magento->getDatabaseWriteConnection();
return $write->delete(
$this->_table_name,
array(
'scope = ?' => $scope,
'scope_id = ?' => $scope_id,
'path = ?' => $path
)
);
}

/**
* @param $path
* @return array
Expand Down
2 changes: 1 addition & 1 deletion src/MageConfigSync/Tests/MagentoTest/a/b/app/Mage.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php /* This file is deliberatly empty. */
<?php /* This file is deliberately empty. */

0 comments on commit f1ef312

Please sign in to comment.