本文整理汇总了PHP中Magento\Framework\App\DeploymentConfig::getConfigData方法的典型用法代码示例。如果您正苦于以下问题:PHP DeploymentConfig::getConfigData方法的具体用法?PHP DeploymentConfig::getConfigData怎么用?PHP DeploymentConfig::getConfigData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\App\DeploymentConfig
的用法示例。
在下文中一共展示了DeploymentConfig::getConfigData方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: read
/**
* 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: testGetters
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: removeModulesFromDeploymentConfig
/**
* 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: _getCacheSettings
/**
* 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: load
/**
* 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: __construct
/**
* @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: deselectDisabledModules
/**
* 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: removeModulesFromDeploymentConfig
/**
* 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: _getCacheFrontendId
/**
* 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: getConnectionByName
/**
* 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: clearInstance
/**
* 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: getDbInstance
/**
* 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: loadConfigData
/**
* 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: assertDbAccessible
/**
* 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]);
}
}