Skip to content

Commit

Permalink
Merge branch 'release/3.3.0' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
therouv committed Aug 6, 2020
2 parents 51b8433 + 9e6c028 commit b4984f6
Show file tree
Hide file tree
Showing 41 changed files with 530 additions and 161 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/.idea
/.php_cs.cache
/phpunit.xml
37 changes: 37 additions & 0 deletions .php_cs.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php
/**
* Copyright © semaio GmbH. All rights reserved.
* See LICENSE.md bundled with this module for license details.
*/

/**
* PHP Coding Standards fixer configuration
*/

$finder = PhpCsFixer\Finder::create()
->in('./')
->name('*.php');

return PhpCsFixer\Config::create()
->setFinder($finder)
->setRules([
'@PSR2' => true,
'array_syntax' => ['syntax' => 'short'],
'concat_space' => ['spacing' => 'one'],
'include' => true,
'new_with_braces' => true,
'no_empty_statement' => true,
'no_extra_consecutive_blank_lines' => true,
'no_leading_import_slash' => true,
'no_leading_namespace_whitespace' => true,
'no_multiline_whitespace_around_double_arrow' => true,
'no_multiline_whitespace_before_semicolons' => true,
'no_singleline_whitespace_before_semicolons' => true,
'no_trailing_comma_in_singleline_array' => true,
'no_unused_imports' => true,
'no_whitespace_in_blank_line' => true,
'object_operator_without_whitespace' => true,
'ordered_imports' => true,
'standardize_not_equals' => true,
'ternary_operator_spaces' => true,
]);
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Changelog

## Release 3.3.0 (2020-08-06)

* Add support for PHP 7.4 and Magento 2.4 ([@DavidLambauer](https://github.com/DavidLambauer)
* Add `no-cache` option to config import [@therouv](https://github.com/therouv)
* Improve docs and code style [@therouv](https://github.com/therouv)
14 changes: 9 additions & 5 deletions Command/AbstractCommand.php
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
<?php
/**
* Copyright © 2016 Rouven Alexander Rieker
* Copyright © semaio GmbH. All rights reserved.
* See LICENSE.md bundled with this module for license details.
*/
namespace Semaio\ConfigImportExport\Command;

use Magento\Framework\App\Area;
use Magento\Framework\App\Cache\Manager as CacheManager;
use Magento\Framework\App\ObjectManager\ConfigLoader;
use Magento\Framework\App\State as AppState;
use Magento\Framework\ObjectManagerInterface;
use Magento\Framework\Registry;
use Magento\Framework\App\Area;
use Magento\Framework\App\Cache\Manager as CacheManager;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Helper\FormatterHelper;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Helper\FormatterHelper;

/**
* Class AbstractCommand
Expand Down Expand Up @@ -105,7 +105,11 @@ protected function execute(InputInterface $input, OutputInterface $output)
$configLoader = $this->objectManager->get('Magento\Framework\ObjectManager\ConfigLoaderInterface');
$this->objectManager->configure($configLoader->load($area));

$this->registry->register('isSecureArea', true);
if ($this->registry->registry('isSecureArea') !== true) {
// Unregister isSecureArea if it is already set and register again
$this->registry->unregister('isSecureArea');
$this->registry->register('isSecureArea', true);
}
}

/**
Expand Down
72 changes: 59 additions & 13 deletions Command/ExportCommand.php
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
<?php
/**
* Copyright © 2016 Rouven Alexander Rieker
* Copyright © semaio GmbH. All rights reserved.
* See LICENSE.md bundled with this module for license details.
*/

namespace Semaio\ConfigImportExport\Command;

use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Magento\Framework\App\Cache\Manager as CacheManager;
use Magento\Framework\App\ObjectManager\ConfigLoader;
use Magento\Framework\App\State as AppState;
use Magento\Framework\ObjectManagerInterface;
use Magento\Framework\Registry;
use Magento\Framework\App\Cache\Manager as CacheManager;
use Semaio\ConfigImportExport\Model\Processor\ExportProcessorInterface;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;

/**
* Class ExportCommand
Expand Down Expand Up @@ -69,13 +70,58 @@ protected function configure()
{
$this->setName(self::COMMAND_NAME);
$this->setDescription('Export settings from "core_config_data" into a file');
$this->addOption('format', 'm', InputOption::VALUE_OPTIONAL, 'Format: yaml, json', 'yaml');
$this->addOption('hierarchical', 'a', InputOption::VALUE_OPTIONAL, 'Create a hierarchical or a flat structure (not all export format supports that). Enable with: y', 'n');
$this->addOption('filename', 'f', InputOption::VALUE_OPTIONAL, 'File name into which should the export be written. Defaults into var directory.');
$this->addOption('include', 'i', InputOption::VALUE_OPTIONAL, 'Path prefix, multiple values can be comma separated; exports only those paths');
$this->addOption('includeScope', null, InputOption::VALUE_OPTIONAL, 'Scope name, multiple values can be comma separated; exports only those scopes');
$this->addOption('exclude', 'x', InputOption::VALUE_OPTIONAL, 'Path prefix, multiple values can be comma separated; exports everything except ...');
$this->addOption('filePerNameSpace', 's', InputOption::VALUE_OPTIONAL, 'Export each namespace into its own file. Enable with: y', 'n');

$this->addOption(
'format',
'm',
InputOption::VALUE_OPTIONAL,
'Format: yaml, json',
'yaml'
);

$this->addOption(
'hierarchical',
'a',
InputOption::VALUE_OPTIONAL,
'Create a hierarchical or a flat structure (not all export format supports that). Enable with: y',
'n'
);

$this->addOption(
'filename',
'f',
InputOption::VALUE_OPTIONAL,
'File name into which should the export be written. Defaults into var directory.'
);

$this->addOption(
'include',
'i',
InputOption::VALUE_OPTIONAL,
'Path prefix, multiple values can be comma separated; exports only those paths'
);

$this->addOption(
'includeScope',
null,
InputOption::VALUE_OPTIONAL,
'Scope name, multiple values can be comma separated; exports only those scopes'
);

$this->addOption(
'exclude',
'x',
InputOption::VALUE_OPTIONAL,
'Path prefix, multiple values can be comma separated; exports everything except ...'
);

$this->addOption(
'filePerNameSpace',
's',
InputOption::VALUE_OPTIONAL,
'Export each namespace into its own file. Enable with: y',
'n'
);

parent::configure();
}
Expand All @@ -101,7 +147,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
throw new \InvalidArgumentException(ucfirst($format) . ' file writer could not be instantiated."');
}

$filename = (string)$input->getOption('filename');
$filename = (string) $input->getOption('filename');
if ($filename != '') {
$writer->setBaseFilename($filename);
}
Expand Down
64 changes: 52 additions & 12 deletions Command/ImportCommand.php
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
<?php
/**
* Copyright © 2016 Rouven Alexander Rieker
* Copyright © semaio GmbH. All rights reserved.
* See LICENSE.md bundled with this module for license details.
*/

namespace Semaio\ConfigImportExport\Command;

use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Magento\Framework\App\Cache\Manager as CacheManager;
use Magento\Framework\App\ObjectManager\ConfigLoader;
use Magento\Framework\App\State as AppState;
use Magento\Framework\ObjectManagerInterface;
use Magento\Framework\Registry;
use Magento\Framework\App\Cache\Manager as CacheManager;
use Semaio\ConfigImportExport\Model\Processor\ImportProcessorInterface;
use Semaio\ConfigImportExport\Model\File\FinderInterface;
use Semaio\ConfigImportExport\Model\Processor\ImportProcessorInterface;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;

/**
* Class ImportCommand
Expand Down Expand Up @@ -69,6 +70,7 @@ public function __construct(
$this->importProcessor = $importProcessor;
$this->readers = $readers;
$this->finder = $finder;

parent::__construct($registry, $appState, $configLoader, $objectManager, $cacheManager, $name);
}

Expand All @@ -79,10 +81,41 @@ protected function configure()
{
$this->setName(self::COMMAND_NAME);
$this->setDescription('Import "core_config_data" settings for an environment');
$this->addArgument('folder', InputArgument::REQUIRED, 'Import folder name');
$this->addArgument('environment', InputArgument::REQUIRED, 'Environment name. SubEnvs separated by slash e.g.: development/osx/developer01');
$this->addOption('base', null, InputOption::VALUE_OPTIONAL, 'Base folder name', 'base');
$this->addOption('format', 'm', InputOption::VALUE_OPTIONAL, 'Format: yaml, json (Default: yaml)', 'yaml');

$this->addArgument(
'folder',
InputArgument::REQUIRED,
'Import folder name'
);

$this->addArgument(
'environment',
InputArgument::REQUIRED,
'Environment name. SubEnvs separated by slash e.g.: development/osx/developer01'
);

$this->addOption(
'base',
null,
InputOption::VALUE_OPTIONAL,
'Base folder name',
'base'
);

$this->addOption(
'format',
'm',
InputOption::VALUE_OPTIONAL,
'Format: yaml, json (Default: yaml)',
'yaml'
);

$this->addOption(
'no-cache',
null,
InputOption::VALUE_NONE,
'Do not clear cache after config data import.',
);

parent::configure();
}
Expand All @@ -95,6 +128,7 @@ protected function configure()
protected function execute(InputInterface $input, OutputInterface $output)
{
parent::execute($input, $output);

$this->writeSection('Start Import');

// Check if there is a reader for the given file extension
Expand Down Expand Up @@ -129,6 +163,12 @@ protected function execute(InputInterface $input, OutputInterface $output)
$this->importProcessor->process();

// Clear the cache after import
$this->getCacheManager()->clean(['config', 'full_page']);
if ($input->getOption('no-cache') === false) {
$this->writeSection('Clear cache');

$this->getCacheManager()->clean(['config', 'full_page']);

$output->writeln(sprintf('<info>Cache cleared.</info>'));
}
}
}
4 changes: 2 additions & 2 deletions Model/Converter/ScopeConvertException.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?php
/**
* Copyright © 2016 Rouven Alexander Rieker
* Copyright © semaio GmbH. All rights reserved.
* See LICENSE.md bundled with this module for license details.
*/

namespace Semaio\ConfigImportExport\Model\Converter;

use RuntimeException;
Expand All @@ -14,5 +15,4 @@
*/
class ScopeConvertException extends RuntimeException
{

}
3 changes: 2 additions & 1 deletion Model/Converter/ScopeConverter.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?php
/**
* Copyright © 2016 Rouven Alexander Rieker
* Copyright © semaio GmbH. All rights reserved.
* See LICENSE.md bundled with this module for license details.
*/

namespace Semaio\ConfigImportExport\Model\Converter;

use Magento\Store\Model\StoreManagerInterface;
Expand Down
3 changes: 2 additions & 1 deletion Model/Converter/ScopeConverterInterface.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?php
/**
* Copyright © 2016 Rouven Alexander Rieker
* Copyright © semaio GmbH. All rights reserved.
* See LICENSE.md bundled with this module for license details.
*/

namespace Semaio\ConfigImportExport\Model\Converter;

/**
Expand Down
3 changes: 2 additions & 1 deletion Model/File/Finder.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?php
/**
* Copyright © 2016 Rouven Alexander Rieker
* Copyright © semaio GmbH. All rights reserved.
* See LICENSE.md bundled with this module for license details.
*/

namespace Semaio\ConfigImportExport\Model\File;

use Symfony\Component\Finder\Finder as SymfonyFinder;
Expand Down
3 changes: 2 additions & 1 deletion Model/File/FinderInterface.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?php
/**
* Copyright © 2016 Rouven Alexander Rieker
* Copyright © semaio GmbH. All rights reserved.
* See LICENSE.md bundled with this module for license details.
*/

namespace Semaio\ConfigImportExport\Model\File;

/**
Expand Down
3 changes: 2 additions & 1 deletion Model/File/Reader/AbstractReader.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?php
/**
* Copyright © 2016 Rouven Alexander Rieker
* Copyright © semaio GmbH. All rights reserved.
* See LICENSE.md bundled with this module for license details.
*/

namespace Semaio\ConfigImportExport\Model\File\Reader;

/**
Expand Down
3 changes: 2 additions & 1 deletion Model/File/Reader/JsonReader.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?php
/**
* Copyright © 2016 Rouven Alexander Rieker
* Copyright © semaio GmbH. All rights reserved.
* See LICENSE.md bundled with this module for license details.
*/

namespace Semaio\ConfigImportExport\Model\File\Reader;

/**
Expand Down
3 changes: 2 additions & 1 deletion Model/File/Reader/ReaderInterface.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?php
/**
* Copyright © 2016 Rouven Alexander Rieker
* Copyright © semaio GmbH. All rights reserved.
* See LICENSE.md bundled with this module for license details.
*/

namespace Semaio\ConfigImportExport\Model\File\Reader;

/**
Expand Down
Loading

0 comments on commit b4984f6

Please sign in to comment.