コード例 #1
0
ファイル: EnvReader.php プロジェクト: Doability/magento2dev
 /**
  * Read communication configuration from env.php
  *
  * @param string|null $scope
  * @return array
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function read($scope = null)
 {
     $configData = $this->deploymentConfig->getConfigData(self::ENV_COMMUNICATION);
     if ($configData) {
         $this->envValidator->validate($configData);
     }
     return $configData ?: [];
 }
コード例 #2
0
 public function testGetters()
 {
     $this->reader->expects($this->once())->method('load')->willReturn(self::$fixture);
     $this->assertSame(self::$flattenedFixture, $this->_deploymentConfig->get());
     // second time to ensure loader will be invoked only once
     $this->assertSame(self::$flattenedFixture, $this->_deploymentConfig->get());
     $this->assertSame('scalar_value', $this->_deploymentConfig->getConfigData('configData1'));
     $this->assertSame(self::$fixture['configData2'], $this->_deploymentConfig->getConfigData('configData2'));
 }
コード例 #3
0
 /**
  * Removes module from deployment configuration
  *
  * @param OutputInterface $output
  * @param string[] $modules
  * @return void
  */
 public function removeModulesFromDeploymentConfig(OutputInterface $output, array $modules)
 {
     $output->writeln('<info>Removing ' . implode(', ', $modules) . ' from module list in deployment configuration</info>');
     $configuredModules = $this->deploymentConfig->getConfigData(\Magento\Framework\Config\ConfigOptionsListConstants::KEY_MODULES);
     $existingModules = $this->loader->load($modules);
     $newModules = [];
     foreach (array_keys($existingModules) as $module) {
         $newModules[$module] = isset($configuredModules[$module]) ? $configuredModules[$module] : 0;
     }
     $this->writer->saveConfig([\Magento\Framework\Config\File\ConfigFilePool::APP_CONFIG => [\Magento\Framework\Config\ConfigOptionsListConstants::KEY_MODULES => $newModules]], true);
 }
コード例 #4
0
ファイル: Pool.php プロジェクト: pradeep-wagento/magento2
 /**
  * Retrieve settings for all cache front-ends known to the system
  *
  * @return array Format: array('<frontend_id>' => array(<cache_settings>), ...)
  */
 protected function _getCacheSettings()
 {
     /*
      * Merging is intentionally implemented through array_merge() instead of array_replace_recursive()
      * to avoid "inheritance" of the default settings that become irrelevant as soon as cache storage type changes
      */
     $cacheInfo = $this->deploymentConfig->getConfigData(FrontendPool::KEY_CACHE);
     if (null !== $cacheInfo) {
         return array_merge($this->_frontendSettings, $cacheInfo[FrontendPool::KEY_FRONTEND_CACHE]);
     }
     return $this->_frontendSettings;
 }
コード例 #5
0
ファイル: State.php プロジェクト: pradeep-wagento/magento2
 /**
  * Load statuses (enabled/disabled) of cache types
  *
  * @return void
  */
 private function load()
 {
     if (null === $this->statuses) {
         $this->statuses = [];
         if ($this->banAll) {
             return;
         }
         $this->statuses = $this->config->getConfigData(self::CACHE_KEY) ?: [];
     }
 }
コード例 #6
0
ファイル: Config.php プロジェクト: opexsw/magento2
 /**
  * @param Config\Reader $reader
  * @param \Magento\Framework\Config\ScopeInterface $configScope
  * @param \Magento\Framework\Config\CacheInterface $cache
  * @param \Magento\Framework\App\DeploymentConfig $deploymentConfig
  * @param string $cacheId
  * @throws \InvalidArgumentException
  */
 public function __construct(Config\Reader $reader, \Magento\Framework\Config\ScopeInterface $configScope, \Magento\Framework\Config\CacheInterface $cache, \Magento\Framework\App\DeploymentConfig $deploymentConfig, $cacheId = 'resourcesCache')
 {
     parent::__construct($reader, $configScope, $cache, $cacheId);
     foreach ($deploymentConfig->getConfigData(ConfigOptionsList::KEY_RESOURCE) as $resourceName => $resourceData) {
         if (!isset($resourceData['connection'])) {
             throw new \InvalidArgumentException('Invalid initial resource configuration');
         }
         $this->_connectionNames[$resourceName] = $resourceData['connection'];
     }
 }
コード例 #7
0
ファイル: ModuleStatus.php プロジェクト: opexsw/magento2
 /**
  * Marks modules that are disabled in deploymentConfig as unselected.
  *
  * @return void
  */
 private function deselectDisabledModules()
 {
     $existingModules = $this->deploymentConfig->getConfigData(ConfigOptionsList::KEY_MODULES);
     if (isset($existingModules)) {
         foreach ($existingModules as $module => $value) {
             if (!$value) {
                 $this->allModules[$module]['selected'] = false;
             }
         }
     }
 }
コード例 #8
0
 /**
  * Removes module from deployment configuration
  *
  * @param string[] $modules
  * @return void
  */
 private function removeModulesFromDeploymentConfig(array $modules)
 {
     $existingModules = $this->deploymentConfig->getConfigData(ConfigOptionsListConstants::KEY_MODULES);
     $newSort = $this->loader->load($modules);
     $newModules = [];
     foreach (array_keys($newSort) as $module) {
         $newModules[$module] = $existingModules[$module];
     }
     $this->writer->saveConfig(
         [ConfigFilePool::APP_CONFIG => [ConfigOptionsListConstants::KEY_MODULES => $newModules]],
         true
     );
 }
コード例 #9
0
ファイル: FrontendPool.php プロジェクト: opexsw/magento2
 /**
  * Retrieve cache frontend identifier, associated with a cache type
  *
  * @param string $cacheType
  * @return string
  */
 protected function _getCacheFrontendId($cacheType)
 {
     $result = null;
     $cacheInfo = $this->deploymentConfig->getConfigData(self::KEY_CACHE);
     if (null !== $cacheInfo) {
         $result = isset($cacheInfo[self::KEY_CACHE_TYPE][$cacheType][self::KEY_FRONTEND_CACHE]) ? $cacheInfo[self::KEY_CACHE_TYPE][$cacheType][self::KEY_FRONTEND_CACHE] : null;
     }
     if (!$result) {
         if (isset($this->_typeFrontendMap[$cacheType])) {
             $result = $this->_typeFrontendMap[$cacheType];
         } else {
             $result = \Magento\Framework\App\Cache\Frontend\Pool::DEFAULT_FRONTEND_ID;
         }
     }
     return $result;
 }
コード例 #10
0
ファイル: Resource.php プロジェクト: opexsw/magento2
 /**
  * Retrieve connection by $connectionName
  *
  * @param string $connectionName
  * @return bool|\Magento\Framework\DB\Adapter\AdapterInterface
  */
 public function getConnectionByName($connectionName)
 {
     if (isset($this->_connections[$connectionName])) {
         return $this->_connections[$connectionName];
     }
     $dbInfo = $this->deploymentConfig->getConfigData(ConfigOptionsList::KEY_DB);
     if (null === $dbInfo) {
         return false;
     }
     $connectionConfig = $dbInfo['connection'][$connectionName];
     if ($connectionConfig) {
         $connection = $this->_connectionFactory->create($connectionConfig);
     }
     if (empty($connection)) {
         return false;
     }
     $this->_connections[$connectionName] = $connection;
     return $connection;
 }
コード例 #11
0
ファイル: AbstractState.php プロジェクト: opexsw/magento2
 /**
  * Clear Magento instance: remove all tables in DB and use dump to load new ones, clear Magento cache
  *
  * @throws \Exception
  */
 public function clearInstance()
 {
     $dirList = \Magento\Mtf\ObjectManagerFactory::getObjectManager()->get('Magento\\Framework\\Filesystem\\DirectoryList');
     $reader = new Reader($dirList);
     $deploymentConfig = new DeploymentConfig($reader);
     $dbConfig = $deploymentConfig->getConfigData(ConfigOptionsList::KEY_DB);
     $dbInfo = $dbConfig['connection']['default'];
     $host = $dbInfo['host'];
     $user = $dbInfo['username'];
     $password = $dbInfo['password'];
     $database = $dbInfo['dbname'];
     $fileName = MTF_BP . '/' . $database . '.sql';
     if (!file_exists($fileName)) {
         echo 'Database dump was not found by path: ' . $fileName;
         return;
     }
     // Drop all tables in database
     $mysqli = new \mysqli($host, $user, $password, $database);
     $mysqli->query('SET foreign_key_checks = 0');
     if ($result = $mysqli->query("SHOW TABLES")) {
         while ($row = $result->fetch_row()) {
             $mysqli->query('DROP TABLE ' . $row[0]);
         }
     }
     $mysqli->query('SET foreign_key_checks = 1');
     $mysqli->close();
     // Load database dump
     exec("mysql -u{$user} -p{$password} {$database} < {$fileName}", $output, $result);
     if ($result) {
         throw new \Exception('Database dump loading has been failed: ' . $output);
     }
     // Clear cache
     exec("rm -rf {$dirList->getPath(DirectoryList::VAR_DIR)}/*", $output, $result);
     if ($result) {
         throw new \Exception('Cleaning Magento cache has been failed: ' . $output);
     }
 }
コード例 #12
0
ファイル: Application.php プロジェクト: opexsw/magento2
 /**
  * Retrieve the database adapter instance
  *
  * @return \Magento\TestFramework\Db\AbstractDb
  */
 public function getDbInstance()
 {
     if (null === $this->_db) {
         if ($this->isInstalled()) {
             $reader = new Reader($this->dirList);
             $deploymentConfig = new DeploymentConfig($reader, []);
             $dbConfig = $deploymentConfig->getConfigData(ConfigOptionsList::KEY_DB);
             $dbInfo = $dbConfig['connection']['default'];
             $host = $dbInfo['host'];
             $user = $dbInfo['username'];
             $password = $dbInfo['password'];
             $dbName = $dbInfo['dbname'];
         } else {
             $installConfig = $this->getInstallConfig();
             $host = $installConfig['db_host'];
             $user = $installConfig['db_user'];
             $password = $installConfig['db_password'];
             $dbName = $installConfig['db_name'];
         }
         $this->_db = new Db\Mysql($host, $user, $password, $dbName, $this->getTempDir(), $this->_shell);
     }
     return $this->_db;
 }
コード例 #13
0
ファイル: ModuleList.php プロジェクト: opexsw/magento2
 /**
  * Loads configuration data only
  *
  * @return void
  */
 private function loadConfigData()
 {
     if (null === $this->configData && $this->config->isAvailable()) {
         $this->configData = $this->config->getConfigData(ConfigOptionsList::KEY_MODULES);
     }
 }
コード例 #14
0
ファイル: Installer.php プロジェクト: opexsw/magento2
 /**
  * Validates that MySQL is accessible and MySQL version is supported
  *
  * @return void
  */
 private function assertDbAccessible()
 {
     $dbConfig = $this->deploymentConfig->getConfigData(ConfigOptionsList::KEY_DB);
     $connectionConfig = $dbConfig['connection'][Config::DEFAULT_SETUP_CONNECTION];
     $this->checkDatabaseConnection($connectionConfig[ConfigOptionsList::KEY_NAME], $connectionConfig[ConfigOptionsList::KEY_HOST], $connectionConfig[ConfigOptionsList::KEY_USER], $connectionConfig[ConfigOptionsList::KEY_PASSWORD]);
     if (isset($connectionConfig[ConfigOptionsList::KEY_PREFIX])) {
         $this->checkDatabaseTablePrefix($connectionConfig[ConfigOptionsList::KEY_PREFIX]);
     }
 }