diff --git a/.gitignore b/.gitignore index 1e6c8cdcecef6cdad04fdea14e744b760cb2816e..2c056b8004d8f1d376078407e9584c4a4e2fa787 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,7 @@ atlassian* /.gitattributes /app/config_sandbox /app/etc/config.php +/app/etc/env.php /app/code/Magento/TestModule* /lib/internal/flex/uploader/.actionScriptProperties /lib/internal/flex/uploader/.flexProperties diff --git a/app/code/Magento/Backend/Setup/ConfigOptionsList.php b/app/code/Magento/Backend/Setup/ConfigOptionsList.php index 83a953cd2f2232cc36e741682e95e3c406dfc194..2acaa7759decb1a0037760480a1be5fbd02bd135 100644 --- a/app/code/Magento/Backend/Setup/ConfigOptionsList.php +++ b/app/code/Magento/Backend/Setup/ConfigOptionsList.php @@ -48,7 +48,7 @@ class ConfigOptionsList implements ConfigOptionsListInterface */ public function createConfig(array $options, DeploymentConfig $deploymentConfig) { - $configData = new ConfigData(ConfigFilePool::APP_CONFIG); + $configData = new ConfigData(ConfigFilePool::APP_ENV); if (isset($options[self::INPUT_KEY_BACKEND_FRONTNAME])) { $configData->set(self::CONFIG_PATH_BACKEND_FRONTNAME, $options[self::INPUT_KEY_BACKEND_FRONTNAME]); diff --git a/app/code/Magento/Backend/Test/Unit/Setup/ConfigOptionsListTest.php b/app/code/Magento/Backend/Test/Unit/Setup/ConfigOptionsListTest.php index 279d11ddfbff83b5cbcbb2b752ea347d8dbe836d..56f18a840a3b6832a40099340927e465f05bf2a0 100644 --- a/app/code/Magento/Backend/Test/Unit/Setup/ConfigOptionsListTest.php +++ b/app/code/Magento/Backend/Test/Unit/Setup/ConfigOptionsListTest.php @@ -42,7 +42,7 @@ class ConfigOptionsListTest extends \PHPUnit_Framework_TestCase $expectedData = [ [ - 'file' => ConfigFilePool::APP_CONFIG, + 'file' => ConfigFilePool::APP_ENV, 'segment' => 'backend', 'data' => [ 'backend' => ['frontName' => 'admin'] diff --git a/dev/tests/functional/lib/Magento/Mtf/App/State/AbstractState.php b/dev/tests/functional/lib/Magento/Mtf/App/State/AbstractState.php index 39d384533ef6dcd6996dc21c8c86b19487dbd932..7548bc922bb4bb3526d91480692d26d9605beef8 100644 --- a/dev/tests/functional/lib/Magento/Mtf/App/State/AbstractState.php +++ b/dev/tests/functional/lib/Magento/Mtf/App/State/AbstractState.php @@ -44,10 +44,12 @@ abstract class AbstractState implements StateInterface $dirList = \Magento\Mtf\ObjectManagerFactory::getObjectManager() ->get('Magento\Framework\Filesystem\DirectoryList'); - $reader = new Reader($dirList); + $configFilePool = \Magento\Mtf\ObjectManagerFactory::getObjectManager() + ->get('\Magento\Framework\Config\File\ConfigFilePool'); + + $reader = new Reader($dirList, $configFilePool); $deploymentConfig = new DeploymentConfig($reader); - $dbConfig = $deploymentConfig->getConfigData(ConfigOptionsList::KEY_DB); - $dbInfo = $dbConfig['connection']['default']; + $dbInfo = $deploymentConfig->get(ConfigOptionsList::CONFIG_PATH_DB_CONNECTION_DEFAULT); $host = $dbInfo['host']; $user = $dbInfo['username']; $password = $dbInfo['password']; diff --git a/dev/tests/integration/framework/Magento/TestFramework/Application.php b/dev/tests/integration/framework/Magento/TestFramework/Application.php index 4d13da77e94c5767525784e06200107926193c3c..ca3ee5dbc85eea4eaa38aba8f5cc54fa306dc2fa 100644 --- a/dev/tests/integration/framework/Magento/TestFramework/Application.php +++ b/dev/tests/integration/framework/Magento/TestFramework/Application.php @@ -162,10 +162,10 @@ class Application { if (null === $this->_db) { if ($this->isInstalled()) { - $reader = new Reader($this->dirList); + $configPool = new \Magento\Framework\Config\File\ConfigFilePool(); + $reader = new Reader($this->dirList, $configPool); $deploymentConfig = new DeploymentConfig($reader, []); - $dbConfig = $deploymentConfig->getConfigData(ConfigOptionsList::KEY_DB); - $dbInfo = $dbConfig['connection']['default']; + $dbInfo = $deploymentConfig->get(ConfigOptionsList::CONFIG_PATH_DB_CONNECTION_DEFAULT); $host = $dbInfo['host']; $user = $dbInfo['username']; $password = $dbInfo['password']; diff --git a/dev/tests/integration/framework/Magento/TestFramework/ObjectManagerFactory.php b/dev/tests/integration/framework/Magento/TestFramework/ObjectManagerFactory.php index e499e0d929ae159842558b2b45a4ece21bde8438..763011a315b36b74eda85e519bc75c04d4644e80 100644 --- a/dev/tests/integration/framework/Magento/TestFramework/ObjectManagerFactory.php +++ b/dev/tests/integration/framework/Magento/TestFramework/ObjectManagerFactory.php @@ -54,7 +54,7 @@ class ObjectManagerFactory extends \Magento\Framework\App\ObjectManagerFactory $objectManager->configure($this->_primaryConfigData); $objectManager->addSharedInstance($this->directoryList, 'Magento\Framework\App\Filesystem\DirectoryList'); $objectManager->addSharedInstance($this->directoryList, 'Magento\Framework\Filesystem\DirectoryList'); - $deploymentConfig = $this->createDeploymentConfig($directoryList, $arguments); + $deploymentConfig = $this->createDeploymentConfig($directoryList, $this->configFilePool, $arguments); $this->factory->setArguments($arguments); $objectManager->addSharedInstance($deploymentConfig, 'Magento\Framework\App\DeploymentConfig'); $objectManager->addSharedInstance( diff --git a/lib/internal/Magento/Framework/App/Bootstrap.php b/lib/internal/Magento/Framework/App/Bootstrap.php index aaf238eadacaa007b8a7abe560095b6125d99c40..05fd99ceaa7d27ff54bc100a84b9d4aaefbb6891 100644 --- a/lib/internal/Magento/Framework/App/Bootstrap.php +++ b/lib/internal/Magento/Framework/App/Bootstrap.php @@ -12,6 +12,7 @@ use Magento\Framework\Autoload\AutoloaderRegistry; use Magento\Framework\Autoload\Populator; use Magento\Framework\Filesystem\DriverPool; use Magento\Framework\Profiler; +use Magento\Framework\Config\File\ConfigFilePool; /** * A bootstrap of Magento application @@ -147,7 +148,8 @@ class Bootstrap { $dirList = self::createFilesystemDirectoryList($rootDir, $initParams); $driverPool = self::createFilesystemDriverPool($initParams); - return new ObjectManagerFactory($dirList, $driverPool); + $configFilePool = self::createConfigFilePool(); + return new ObjectManagerFactory($dirList, $driverPool, $configFilePool); } /** @@ -181,6 +183,16 @@ class Bootstrap return new DriverPool($extraDrivers); } + /** + * Creates instance of configuration files pool + * + * @return DriverPool + */ + public static function createConfigFilePool() + { + return new ConfigFilePool(); + } + /** * Constructor * diff --git a/lib/internal/Magento/Framework/App/Cache/State.php b/lib/internal/Magento/Framework/App/Cache/State.php index d7de86d9ba359c7599e9842f86200ec519d5c683..20d55a3f001fc3c7622309455cab0b280aa3be25 100644 --- a/lib/internal/Magento/Framework/App/Cache/State.php +++ b/lib/internal/Magento/Framework/App/Cache/State.php @@ -98,7 +98,7 @@ class State implements StateInterface public function persist() { $this->load(); - $this->writer->saveConfig([ConfigFilePool::APP_CONFIG => [self::CACHE_KEY => $this->statuses]]); + $this->writer->saveConfig([ConfigFilePool::APP_ENV => [self::CACHE_KEY => $this->statuses]]); } /** diff --git a/lib/internal/Magento/Framework/App/DeploymentConfig/Reader.php b/lib/internal/Magento/Framework/App/DeploymentConfig/Reader.php index de210b428710589464c895aa9fa6590adc5199fc..ecc591efecc7993cc31f71365d673c498b16b890 100644 --- a/lib/internal/Magento/Framework/App/DeploymentConfig/Reader.php +++ b/lib/internal/Magento/Framework/App/DeploymentConfig/Reader.php @@ -7,6 +7,7 @@ namespace Magento\Framework\App\DeploymentConfig; use Magento\Framework\App\Filesystem\DirectoryList; +use Magento\Framework\Config\File\ConfigFilePool; /** * Deployment configuration reader @@ -14,69 +15,80 @@ use Magento\Framework\App\Filesystem\DirectoryList; class Reader { /** - * Default configuration file name + * @var DirectoryList */ - const DEFAULT_FILE = 'config.php'; + private $dirList; /** - * Directory list object - * - * @var DirectoryList + * @var ConfigFilePool */ - private $dirList; + private $configFilePool; /** - * Custom file name + * Configuration file names * - * @var string + * @var array */ - private $file; + private $files; /** * Constructor * * @param DirectoryList $dirList + * @param ConfigFilePool $configFilePool * @param null|string $file * @throws \InvalidArgumentException */ - public function __construct(DirectoryList $dirList, $file = null) + public function __construct(DirectoryList $dirList, ConfigFilePool $configFilePool, $file = null) { $this->dirList = $dirList; + $this->configFilePool = $configFilePool; if (null !== $file) { if (!preg_match('/^[a-z\d\.\-]+\.php$/i', $file)) { throw new \InvalidArgumentException("Invalid file name: {$file}"); } - $this->file = $file; + $this->files = [$file]; } else { - $this->file = self::DEFAULT_FILE; + $this->files = $this->configFilePool->getPaths(); } } /** * Gets the file name * - * @return string + * @return array */ - public function getFile() + public function getFiles() { - return $this->file; + return $this->files; } /** * Loads the configuration file * * @param string $configFile + * @throws \Exception * @return array */ public function load($configFile = null) { + $path = $this->dirList->getPath(DirectoryList::CONFIG); if ($configFile) { - $file = $this->dirList->getPath(DirectoryList::CONFIG) . '/' . $configFile; + $result = @include $path . '/' . $this->configFilePool->getPath($configFile); } else { - $file = $this->dirList->getPath(DirectoryList::CONFIG) . '/' . $this->file; - } + $configFiles = $this->configFilePool->getPaths(); + $result = []; + foreach ($configFiles as $fileKey => $config) { + $configFile = $path . '/' . $this->configFilePool->getPath($fileKey); + $fileData = @include $configFile; - $result = @include $file; + if (empty(array_intersect_key($result, $fileData))) { + $result = array_replace_recursive($result, $fileData ?: []); + } else { + throw new \Exception('Duplicate keys are present'); + } + } + } return $result ?: []; } } diff --git a/lib/internal/Magento/Framework/App/DeploymentConfig/Writer.php b/lib/internal/Magento/Framework/App/DeploymentConfig/Writer.php index 644af48555deb9f25c86d5011021a9d9bce262c7..8d447e295bf4cb8ade19fc1eca90676b7b6e209b 100644 --- a/lib/internal/Magento/Framework/App/DeploymentConfig/Writer.php +++ b/lib/internal/Magento/Framework/App/DeploymentConfig/Writer.php @@ -78,10 +78,12 @@ class Writer public function checkIfWritable() { $configDirectory = $this->filesystem->getDirectoryWrite(DirectoryList::CONFIG); - if ($configDirectory->isWritable($this->reader->getFile())) { - return true; + foreach ($this->reader->getFiles() as $file) { + if (!$configDirectory->isWritable($file)) { + return false; + } } - return false; + return true; } /** @@ -99,7 +101,7 @@ class Writer if (isset($paths[$fileKey])) { if ($this->filesystem->getDirectoryWrite(DirectoryList::CONFIG)->isExist($paths[$fileKey])) { - $currentData = $this->reader->load($paths[$fileKey]); + $currentData = $this->reader->load($fileKey); if ($override) { $config = array_merge($currentData, $config); } else { diff --git a/lib/internal/Magento/Framework/App/ObjectManagerFactory.php b/lib/internal/Magento/Framework/App/ObjectManagerFactory.php index c712e82a26470f58683f0fc2af9a0b74cba6540e..fff951bef2503fa905e96b27d038192e6294ae47 100644 --- a/lib/internal/Magento/Framework/App/ObjectManagerFactory.php +++ b/lib/internal/Magento/Framework/App/ObjectManagerFactory.php @@ -12,8 +12,7 @@ use Magento\Framework\Filesystem\DriverPool; use Magento\Framework\Interception\ObjectManager\ConfigInterface; use Magento\Framework\ObjectManager\Definition\Compiled\Serialized; use Magento\Framework\App\ObjectManager\Environment; -use Magento\Framework\App\EnvironmentFactory; -use Magento\Framework\App\EnvironmentInterface; +use Magento\Framework\Config\File\ConfigFilePool; /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) @@ -71,6 +70,13 @@ class ObjectManagerFactory */ protected $driverPool; + /** + * Configuration file pool + * + * @var ConfigFilePool + */ + protected $configFilePool; + /** * Factory * @@ -83,11 +89,13 @@ class ObjectManagerFactory * * @param DirectoryList $directoryList * @param DriverPool $driverPool + * @param ConfigFilePool $configFilePool */ - public function __construct(DirectoryList $directoryList, DriverPool $driverPool) + public function __construct(DirectoryList $directoryList, DriverPool $driverPool, ConfigFilePool $configFilePool) { $this->directoryList = $directoryList; $this->driverPool = $driverPool; + $this->configFilePool = $configFilePool; } /** @@ -100,7 +108,7 @@ class ObjectManagerFactory */ public function create(array $arguments) { - $deploymentConfig = $this->createDeploymentConfig($this->directoryList, $arguments); + $deploymentConfig = $this->createDeploymentConfig($this->directoryList, $this->configFilePool, $arguments); $arguments = array_merge($deploymentConfig->get(), $arguments); $definitionFactory = new \Magento\Framework\ObjectManager\DefinitionFactory( $this->driverPool->getDriver(DriverPool::FILE), @@ -179,10 +187,11 @@ class ObjectManagerFactory * Creates deployment configuration object * * @param DirectoryList $directoryList + * @param ConfigFilePool $configFilePool * @param array $arguments * @return DeploymentConfig */ - protected function createDeploymentConfig(DirectoryList $directoryList, array $arguments) + protected function createDeploymentConfig(DirectoryList $directoryList, ConfigFilePool $configFilePool, array $arguments) { $customFile = isset($arguments[self::INIT_PARAM_DEPLOYMENT_CONFIG_FILE]) ? $arguments[self::INIT_PARAM_DEPLOYMENT_CONFIG_FILE] @@ -190,7 +199,7 @@ class ObjectManagerFactory $customData = isset($arguments[self::INIT_PARAM_DEPLOYMENT_CONFIG]) ? $arguments[self::INIT_PARAM_DEPLOYMENT_CONFIG] : []; - $reader = new DeploymentConfig\Reader($directoryList, $customFile); + $reader = new DeploymentConfig\Reader($directoryList, $configFilePool, $customFile); return new DeploymentConfig($reader, $customData); } diff --git a/lib/internal/Magento/Framework/App/Resource.php b/lib/internal/Magento/Framework/App/Resource.php index b38629a460a4fa8a7ed78c1a9e77450ec23c1c8a..02edd51d59987d919ee4d9ed9a3099387386b008 100644 --- a/lib/internal/Magento/Framework/App/Resource.php +++ b/lib/internal/Magento/Framework/App/Resource.php @@ -104,11 +104,8 @@ class Resource return $this->_connections[$connectionName]; } - $dbInfo = $this->deploymentConfig->getConfigData(ConfigOptionsList::KEY_DB); - if (null === $dbInfo) { - return false; - } - $connectionConfig = $dbInfo['connection'][$connectionName]; + $connections = $this->deploymentConfig->get(ConfigOptionsList::CONFIG_PATH_DB_CONNECTIONS); + $connectionConfig = $connections[$connectionName]; if ($connectionConfig) { $connection = $this->_connectionFactory->create($connectionConfig); } diff --git a/lib/internal/Magento/Framework/App/Test/Unit/Cache/StateTest.php b/lib/internal/Magento/Framework/App/Test/Unit/Cache/StateTest.php index c5767244b54ee3c423e8057e271f229993b68b5b..8278d0fdfe45b9bc5079a257fb6b1eaf1245dab6 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/Cache/StateTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/Cache/StateTest.php @@ -93,7 +93,7 @@ class StateTest extends \PHPUnit_Framework_TestCase { $model = new State($this->config, $this->writer); $this->config->expects($this->once())->method('getConfigData')->willReturn(['test_cache_type' => true]); - $configValue = [ConfigFilePool::APP_CONFIG => ['cache_types' => ['test_cache_type' => true]]]; + $configValue = [ConfigFilePool::APP_ENV => ['cache_types' => ['test_cache_type' => true]]]; $this->writer->expects($this->once())->method('saveConfig')->with($configValue); $model->persist(); } diff --git a/lib/internal/Magento/Framework/App/Test/Unit/DeploymentConfig/ReaderTest.php b/lib/internal/Magento/Framework/App/Test/Unit/DeploymentConfig/ReaderTest.php index a1bce3da6da246af4888f7eb5777ced5e503de5f..561a496192003e39fbb4feaa57c2b200bae29bf1 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/DeploymentConfig/ReaderTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/DeploymentConfig/ReaderTest.php @@ -6,9 +6,9 @@ namespace Magento\Framework\App\Test\Unit\DeploymentConfig; -use \Magento\Framework\App\DeploymentConfig\Reader; - +use Magento\Framework\App\DeploymentConfig\Reader; use Magento\Framework\App\Filesystem\DirectoryList; +use Magento\Framework\Config\File\ConfigFilePool; class ReaderTest extends \PHPUnit_Framework_TestCase { @@ -17,17 +17,33 @@ class ReaderTest extends \PHPUnit_Framework_TestCase */ private $dirList; + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + private $configFilePool; + protected function setUp() { $this->dirList = $this->getMock('Magento\Framework\App\Filesystem\DirectoryList', [], [], '', false); + $this->dirList->expects($this->any()) + ->method('getPath') + ->with(DirectoryList::CONFIG) + ->willReturn(__DIR__ . '/_files'); + $this->configFilePool = $this->getMock('Magento\Framework\Config\File\ConfigFilePool', [], [], '', false); + $this->configFilePool + ->expects($this->any()) + ->method('getPaths') + ->willReturn(['configKeyOne' => 'config.php', 'configKeyTwo' => 'env.php']); } public function testGetFile() { - $object = new Reader($this->dirList); - $this->assertEquals(Reader::DEFAULT_FILE, $object->getFile()); - $object = new Reader($this->dirList, 'custom.php'); - $this->assertEquals('custom.php', $object->getFile()); + $object = new Reader($this->dirList, $this->configFilePool); + $files = $object->getFiles(); + $this->assertArrayHasKey('configKeyOne', $files); + $this->assertArrayHasKey('configKeyTwo', $files); + $object = new Reader($this->dirList, $this->configFilePool, 'customOne.php'); + $this->assertEquals(['customOne.php'], $object->getFiles()); } /** @@ -36,34 +52,62 @@ class ReaderTest extends \PHPUnit_Framework_TestCase */ public function testWrongFile() { - new Reader($this->dirList, 'invalid_name'); + new Reader($this->dirList, $this->configFilePool, 'invalid_name'); + } + + public function testLoad() + { + $files = [['configKeyOne', 'config.php'], ['configKeyTwo','env.php']]; + $this->configFilePool + ->expects($this->any()) + ->method('getPath') + ->will($this->returnValueMap($files)); + $object = new Reader($this->dirList, $this->configFilePool); + $this->assertSame(['fooKey' =>'foo', 'barKey' => 'bar', 'envKey' => 'env'], $object->load()); } /** * @param string $file * @param array $expected - * @dataProvider loadDataProvider + * @dataProvider loadCustomDataProvider */ - public function testLoad($file, $expected) + public function testCustomLoad($file, $expected) { - $this->dirList->expects($this->once()) - ->method('getPath') - ->with(DirectoryList::CONFIG) - ->willReturn(__DIR__ . '/_files'); - $object = new Reader($this->dirList, $file); - $this->assertSame($expected, $object->load()); + $configFilePool = $this->getMock('Magento\Framework\Config\File\ConfigFilePool', [], [], '', false); + $configFilePool->expects($this->any())->method('getPaths')->willReturn(['custom.php']); + $configFilePool->expects($this->any())->method('getPath')->willReturn('custom.php'); + $object = new Reader($this->dirList, $configFilePool, 'custom.php'); + $this->assertSame(['bazKey' => 'baz'], $object->load()); } /** * @return array */ - public function loadDataProvider() + public function loadCustomDataProvider() { return [ - [null, ['foo', 'bar']], - ['config.php', ['foo', 'bar']], - ['custom.php', ['baz']], - ['nonexistent.php', []] + ['custom.php', ['bazKey' => 'baz']], + ['nonexistent.php', []], ]; } + + /** + * @expectedException \Exception + * @expectedExceptionMessage Duplicate keys are present + */ + public function testDuplicateLoad() + { + $configFilePool = $this->getMock('Magento\Framework\Config\File\ConfigFilePool', [], [], '', false); + $files = [['configKeyOne', 'config.php'], ['configKeyTwo','duplicateConfig.php']]; + $configFilePool + ->expects($this->any()) + ->method('getPath') + ->will($this->returnValueMap($files)); + $configFilePool + ->expects($this->any()) + ->method('getPaths') + ->willReturn(['configKeyOne' => 'config.php', 'configKeyTwo' => 'duplicateConfig.php']); + $object = new Reader($this->dirList, $configFilePool); + $this->assertSame(['fooKey' =>'foo', 'barKey' => 'bar'], $object->load()); + } } diff --git a/lib/internal/Magento/Framework/App/Test/Unit/DeploymentConfig/WriterTest.php b/lib/internal/Magento/Framework/App/Test/Unit/DeploymentConfig/WriterTest.php index e1ab784199fa34bc212def1f33439c07ffc8df50..d9494ec1c3c4838fc0ffc0019116b2616fe57d4c 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/DeploymentConfig/WriterTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/DeploymentConfig/WriterTest.php @@ -59,7 +59,7 @@ class WriterTest extends \PHPUnit_Framework_TestCase $this->deploymentConfig, $this->formatter ); - $this->reader->expects($this->any())->method('getFile')->willReturn('test.php'); + $this->reader->expects($this->any())->method('getFiles')->willReturn('test.php'); $this->dirWrite = $this->getMockForAbstractClass('Magento\Framework\Filesystem\Directory\WriteInterface'); $filesystem->expects($this->any()) ->method('getDirectoryWrite') diff --git a/lib/internal/Magento/Framework/App/Test/Unit/DeploymentConfig/_files/config.php b/lib/internal/Magento/Framework/App/Test/Unit/DeploymentConfig/_files/config.php index e5519913e59aa3cd08821152355d20f408e26d14..569b3df839882f3fa6f52ddcab2626305471a1ac 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/DeploymentConfig/_files/config.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/DeploymentConfig/_files/config.php @@ -4,4 +4,4 @@ * See COPYING.txt for license details. */ -return ['foo', 'bar']; +return ['fooKey' => 'foo', 'barKey' => 'bar']; diff --git a/lib/internal/Magento/Framework/App/Test/Unit/DeploymentConfig/_files/custom.php b/lib/internal/Magento/Framework/App/Test/Unit/DeploymentConfig/_files/custom.php index 22cd13edb674610fe2c611337fc431f557ff10db..4e57bcc51584644e8457e4223fc1666e17897d4b 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/DeploymentConfig/_files/custom.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/DeploymentConfig/_files/custom.php @@ -4,4 +4,4 @@ * See COPYING.txt for license details. */ -return ['baz']; +return ['bazKey' => 'baz']; diff --git a/lib/internal/Magento/Framework/App/Test/Unit/DeploymentConfig/_files/duplicateConfig.php b/lib/internal/Magento/Framework/App/Test/Unit/DeploymentConfig/_files/duplicateConfig.php new file mode 100644 index 0000000000000000000000000000000000000000..c344e00adae9cd698bf4afb6d00825fe9e259c2c --- /dev/null +++ b/lib/internal/Magento/Framework/App/Test/Unit/DeploymentConfig/_files/duplicateConfig.php @@ -0,0 +1,9 @@ +<?php +/** + * {license_notice} + * + * @copyright {copyright} + * @license {license_link} + */ + +return ['barKey' => 'someOtherBar']; diff --git a/lib/internal/Magento/Framework/App/Test/Unit/DeploymentConfig/_files/env.php b/lib/internal/Magento/Framework/App/Test/Unit/DeploymentConfig/_files/env.php new file mode 100644 index 0000000000000000000000000000000000000000..660088939bca8ce42c12bf5e5c0aa7bce50b5e73 --- /dev/null +++ b/lib/internal/Magento/Framework/App/Test/Unit/DeploymentConfig/_files/env.php @@ -0,0 +1,7 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +return ['envKey' => 'env']; diff --git a/lib/internal/Magento/Framework/Config/ConfigGenerator.php b/lib/internal/Magento/Framework/Config/ConfigGenerator.php index c7f4ac934ae47cf91fd90dff233df5c24a611a3c..dd15c2cae8c831bce81973ec7fb829d32f5b3322 100644 --- a/lib/internal/Magento/Framework/Config/ConfigGenerator.php +++ b/lib/internal/Magento/Framework/Config/ConfigGenerator.php @@ -63,7 +63,7 @@ class ConfigGenerator */ public function createInstallConfig() { - $configData = new ConfigData(ConfigFilePool::APP_CONFIG); + $configData = new ConfigData(ConfigFilePool::APP_ENV); if ($this->deploymentConfig->get(ConfigOptionsList::CONFIG_PATH_INSTALL_DATE) === null) { $configData->set(ConfigOptionsList::CONFIG_PATH_INSTALL_DATE, date('r')); @@ -80,7 +80,7 @@ class ConfigGenerator { $currentKey = $this->deploymentConfig->get(ConfigOptionsList::CONFIG_PATH_CRYPT_KEY); - $configData = new ConfigData(ConfigFilePool::APP_CONFIG); + $configData = new ConfigData(ConfigFilePool::APP_ENV); if (isset($data[ConfigOptionsList::INPUT_KEY_ENCRYPTION_KEY])) { if ($currentKey !== null) { $key = $currentKey . "\n" . $data[ConfigOptionsList::INPUT_KEY_ENCRYPTION_KEY]; @@ -106,7 +106,7 @@ class ConfigGenerator */ public function createSessionConfig(array $data) { - $configData = new ConfigData(ConfigFilePool::APP_CONFIG); + $configData = new ConfigData(ConfigFilePool::APP_ENV); if (isset($data[ConfigOptionsList::INPUT_KEY_SESSION_SAVE])) { $configData->set( @@ -126,7 +126,7 @@ class ConfigGenerator */ public function createDefinitionsConfig(array $data) { - $configData = new ConfigData(ConfigFilePool::APP_CONFIG); + $configData = new ConfigData(ConfigFilePool::APP_ENV); if (!empty($data[ConfigOptionsList::INPUT_KEY_DEFINITION_FORMAT])) { $configData->set( @@ -146,7 +146,7 @@ class ConfigGenerator */ public function createDbConfig(array $data) { - $configData = new ConfigData(ConfigFilePool::APP_CONFIG); + $configData = new ConfigData(ConfigFilePool::APP_ENV); $optional = [ ConfigOptionsList::INPUT_KEY_DB_HOST, @@ -188,7 +188,7 @@ class ConfigGenerator */ public function createResourceConfig() { - $configData = new ConfigData(ConfigFilePool::APP_CONFIG); + $configData = new ConfigData(ConfigFilePool::APP_ENV); if ($this->deploymentConfig->get(ConfigOptionsList::CONFIG_PATH_RESOURCE_DEFAULT_SETUP) === null) { $configData->set(ConfigOptionsList::CONFIG_PATH_RESOURCE_DEFAULT_SETUP, 'default'); diff --git a/lib/internal/Magento/Framework/Config/ConfigOptionsList.php b/lib/internal/Magento/Framework/Config/ConfigOptionsList.php index ac1a90652f40c07dc382b094e655a4cd289a5700..0e994e29ac29d9cb0ada237f4c19ba0a3065122c 100644 --- a/lib/internal/Magento/Framework/Config/ConfigOptionsList.php +++ b/lib/internal/Magento/Framework/Config/ConfigOptionsList.php @@ -25,6 +25,7 @@ class ConfigOptionsList implements ConfigOptionsListInterface const CONFIG_PATH_DEFINITION_FORMAT = 'definition/format'; const CONFIG_PATH_RESOURCE_DEFAULT_SETUP = 'resource/default_setup/connection'; const CONFIG_PATH_DB_CONNECTION_DEFAULT = 'db/connection/default/'; + const CONFIG_PATH_DB_CONNECTIONS= 'db/connection/'; const CONFIG_PATH_DB_PREFIX = 'db/table_prefix'; /**#@-*/ diff --git a/lib/internal/Magento/Framework/Config/File/ConfigFilePool.php b/lib/internal/Magento/Framework/Config/File/ConfigFilePool.php index 882e846ec144ed7ea4d8bd027ef4ac71970ab207..b1d8e2d462371ab23856af5136440a7e8676c64e 100644 --- a/lib/internal/Magento/Framework/Config/File/ConfigFilePool.php +++ b/lib/internal/Magento/Framework/Config/File/ConfigFilePool.php @@ -6,14 +6,13 @@ namespace Magento\Framework\Config\File; -use Magento\Framework\App\Filesystem\DirectoryList; - /** * Stores file key to file name config */ class ConfigFilePool { const APP_CONFIG = 'app_config'; + const APP_ENV = 'app_env'; /** * Default application config @@ -21,7 +20,8 @@ class ConfigFilePool * @var array */ private $applicationConfigFiles = [ - self::APP_CONFIG => 'config.php' + self::APP_CONFIG => 'config.php', + self::APP_ENV => 'env.php', ]; /** diff --git a/lib/internal/Magento/Framework/Config/Test/Unit/ConfigGeneratorTest.php b/lib/internal/Magento/Framework/Config/Test/Unit/ConfigGeneratorTest.php index 8479894c4e7bacb3c9aaf15b4e01ef92877cbd27..fd6498d592442b5c56daefe9069e69eb89d1dfb1 100644 --- a/lib/internal/Magento/Framework/Config/Test/Unit/ConfigGeneratorTest.php +++ b/lib/internal/Magento/Framework/Config/Test/Unit/ConfigGeneratorTest.php @@ -29,21 +29,21 @@ class ConfigGeneratorTest extends \PHPUnit_Framework_TestCase { $returnValue = $this->configGeneratorObject->createInstallConfig([]); $this->assertInstanceOf('Magento\Framework\Config\Data\ConfigData', $returnValue); - $this->assertEquals(ConfigFilePool::APP_CONFIG, $returnValue->getFileKey()); + $this->assertEquals(ConfigFilePool::APP_ENV, $returnValue->getFileKey()); } public function testCreateCryptConfigWithInput() { $testData = [ConfigOptionsList::INPUT_KEY_ENCRYPTION_KEY => 'some-test_key']; $returnValue = $this->configGeneratorObject->createCryptConfig($testData); - $this->assertEquals(ConfigFilePool::APP_CONFIG, $returnValue->getFileKey()); + $this->assertEquals(ConfigFilePool::APP_ENV, $returnValue->getFileKey()); $this->assertEquals(['crypt' => ['key' => 'some-test_key']], $returnValue->getData()); } public function testCreateCryptConfigWithoutInput() { $returnValue = $this->configGeneratorObject->createCryptConfig([]); - $this->assertEquals(ConfigFilePool::APP_CONFIG, $returnValue->getFileKey()); + $this->assertEquals(ConfigFilePool::APP_ENV, $returnValue->getFileKey()); $this->assertEquals(['crypt' => ['key' => md5('key')]], $returnValue->getData()); } @@ -51,19 +51,19 @@ class ConfigGeneratorTest extends \PHPUnit_Framework_TestCase { $testData = [ConfigOptionsList::INPUT_KEY_SESSION_SAVE => 'files']; $returnValue = $this->configGeneratorObject->createSessionConfig($testData); - $this->assertEquals(ConfigFilePool::APP_CONFIG, $returnValue->getFileKey()); + $this->assertEquals(ConfigFilePool::APP_ENV, $returnValue->getFileKey()); $this->assertEquals(['session' => ['save' => ConfigOptionsList::SESSION_SAVE_FILES]], $returnValue->getData()); $testData = [ConfigOptionsList::INPUT_KEY_SESSION_SAVE => 'db']; $returnValue = $this->configGeneratorObject->createSessionConfig($testData); - $this->assertEquals(ConfigFilePool::APP_CONFIG, $returnValue->getFileKey()); + $this->assertEquals(ConfigFilePool::APP_ENV, $returnValue->getFileKey()); $this->assertEquals(['session' => ['save' => ConfigOptionsList::SESSION_SAVE_DB]], $returnValue->getData()); } public function testCreateSessionConfigWithoutInput() { $returnValue = $this->configGeneratorObject->createSessionConfig([]); - $this->assertEquals(ConfigFilePool::APP_CONFIG, $returnValue->getFileKey()); + $this->assertEquals(ConfigFilePool::APP_ENV, $returnValue->getFileKey()); $this->assertEquals([], $returnValue->getData()); } @@ -71,7 +71,7 @@ class ConfigGeneratorTest extends \PHPUnit_Framework_TestCase { $testData = [\Magento\Framework\Config\ConfigOptionsList::INPUT_KEY_DEFINITION_FORMAT => 'test-format']; $returnValue = $this->configGeneratorObject->createDefinitionsConfig($testData); - $this->assertEquals(ConfigFilePool::APP_CONFIG, $returnValue->getFileKey()); + $this->assertEquals(ConfigFilePool::APP_ENV, $returnValue->getFileKey()); $this->assertEquals(['definition' => ['format' => 'test-format']], $returnValue->getData()); } @@ -84,7 +84,7 @@ class ConfigGeneratorTest extends \PHPUnit_Framework_TestCase ConfigOptionsList::INPUT_KEY_DB_PREFIX => 'testSomePrefix', ]; $returnValue = $this->configGeneratorObject->createDbConfig($testData); - $this->assertEquals(ConfigFilePool::APP_CONFIG, $returnValue->getFileKey()); + $this->assertEquals(ConfigFilePool::APP_ENV, $returnValue->getFileKey()); $dbData = $returnValue->getData(); $dbData = $dbData['db']; $this->assertArrayHasKey('table_prefix', $dbData); @@ -104,7 +104,7 @@ class ConfigGeneratorTest extends \PHPUnit_Framework_TestCase public function testCreateResourceConfig() { $returnValue = $this->configGeneratorObject->createResourceConfig(); - $this->assertEquals(ConfigFilePool::APP_CONFIG, $returnValue->getFileKey()); + $this->assertEquals(ConfigFilePool::APP_ENV, $returnValue->getFileKey()); $this->assertEquals(['resource' => ['default_setup' => ['connection' => 'default']]], $returnValue->getData()); } } diff --git a/lib/internal/Magento/Framework/Config/Test/Unit/File/ConfigFilePoolTest.php b/lib/internal/Magento/Framework/Config/Test/Unit/File/ConfigFilePoolTest.php index 52bc10dc59b897dcf36635bcec5a923cfe9924ab..24452acb4336f6a3c2786d9f4d5e3350332e45bd 100644 --- a/lib/internal/Magento/Framework/Config/Test/Unit/File/ConfigFilePoolTest.php +++ b/lib/internal/Magento/Framework/Config/Test/Unit/File/ConfigFilePoolTest.php @@ -27,6 +27,7 @@ class ConfigFilePoolTest extends \PHPUnit_Framework_TestCase { $expected['new_key'] = 'new_config.php'; $expected[ConfigFilePool::APP_CONFIG] = 'config.php'; + $expected[ConfigFilePool::APP_ENV] = 'env.php'; $this->assertEquals($expected, $this->configFilePool->getPaths()); } diff --git a/lib/internal/Magento/Framework/Module/ModuleList.php b/lib/internal/Magento/Framework/Module/ModuleList.php index aa5cf2dc92096857796e6f947421e7460011adf1..604d43fa04c4f00f7f987307fee909f0003dd651 100644 --- a/lib/internal/Magento/Framework/Module/ModuleList.php +++ b/lib/internal/Magento/Framework/Module/ModuleList.php @@ -140,7 +140,7 @@ class ModuleList implements ModuleListInterface private function loadConfigData() { if (null === $this->configData && ($this->config->isAvailable())) { - $this->configData = $this->config->getConfigData(ConfigOptionsList::KEY_MODULES); + $this->configData = $this->config->get(ConfigOptionsList::KEY_MODULES); } } } diff --git a/setup/src/Magento/Setup/Model/Installer.php b/setup/src/Magento/Setup/Model/Installer.php index 5db3a546a66113ea49ff556c9f346281ec8afc44..a3a8f298bbdaec103f4320dcdaa609f5d183f8aa 100644 --- a/setup/src/Magento/Setup/Model/Installer.php +++ b/setup/src/Magento/Setup/Model/Installer.php @@ -1028,9 +1028,7 @@ class Installer { // stops cleanup if app/etc/config.php does not exist if ($this->deploymentConfig->isAvailable()) { - $dbConfig = $this->deploymentConfig->getConfigData(ConfigOptionsList::KEY_DB); - $config = $dbConfig['connection'][Config::DEFAULT_SETUP_CONNECTION]; - + $config = $this->deploymentConfig->get(ConfigOptionsList::CONFIG_PATH_DB_CONNECTION_DEFAULT); if ($config) { try { $connection = $this->connectionFactory->create($config); @@ -1093,8 +1091,7 @@ class Installer */ private function assertDbAccessible() { - $dbConfig = $this->deploymentConfig->getConfigData(ConfigOptionsList::KEY_DB); - $connectionConfig = $dbConfig['connection'][Config::DEFAULT_SETUP_CONNECTION]; + $connectionConfig = $this->deploymentConfig->get(ConfigOptionsList::CONFIG_PATH_DB_CONNECTION_DEFAULT); $this->checkDatabaseConnection( $connectionConfig[ConfigOptionsList::KEY_NAME], $connectionConfig[ConfigOptionsList::KEY_HOST], diff --git a/setup/src/Magento/Setup/Model/ModuleStatus.php b/setup/src/Magento/Setup/Model/ModuleStatus.php index d49206b274a48766392312f64fb78e5fcb7eed96..bfc8d9349a349b02267b57510a9ab59c73697915 100644 --- a/setup/src/Magento/Setup/Model/ModuleStatus.php +++ b/setup/src/Magento/Setup/Model/ModuleStatus.php @@ -145,7 +145,7 @@ class ModuleStatus */ private function deselectDisabledModules() { - $existingModules = $this->deploymentConfig->getConfigData(ConfigOptionsList::KEY_MODULES); + $existingModules = $this->deploymentConfig->get(ConfigOptionsList::KEY_MODULES); if (isset($existingModules)) { foreach ($existingModules as $module => $value) { if (!$value) {