本文整理汇总了PHP中Magento\Framework\App\DeploymentConfig::getSegment方法的典型用法代码示例。如果您正苦于以下问题:PHP DeploymentConfig::getSegment方法的具体用法?PHP DeploymentConfig::getSegment怎么用?PHP DeploymentConfig::getSegment使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\App\DeploymentConfig
的用法示例。
在下文中一共展示了DeploymentConfig::getSegment方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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->getSegment('segment1'));
$this->assertSame(self::$fixture['segment2'], $this->_deploymentConfig->getSegment('segment2'));
}
示例2: _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->getSegment(CacheConfig::CONFIG_KEY);
if (null !== $cacheInfo) {
$cacheConfig = new CacheConfig($cacheInfo);
return array_merge($this->_frontendSettings, $cacheConfig->getCacheFrontendSettings());
}
return $this->_frontendSettings;
}
示例3: toOptionArray
/**
* Returns list of available resources
*
* @return array
*/
public function toOptionArray()
{
$resourceOptions = [];
$resourceInfo = $this->_deploymentConfig->getSegment(ResourceConfig::CONFIG_KEY);
if (null !== $resourceInfo) {
$resourceConfig = new ResourceConfig($resourceInfo);
foreach (array_keys($resourceConfig->getData()) as $resourceName) {
$resourceOptions[] = ['value' => $resourceName, 'label' => $resourceName];
}
sort($resourceOptions);
reset($resourceOptions);
}
return $resourceOptions;
}
示例4: _getCacheFrontendId
/**
* Retrieve cache frontend identifier, associated with a cache type
*
* @param string $cacheType
* @return string
*/
protected function _getCacheFrontendId($cacheType)
{
$result = null;
$cacheInfo = $this->_deploymentConfig->getSegment(CacheConfig::CONFIG_KEY);
if (null !== $cacheInfo) {
$cacheConfig = new CacheConfig($cacheInfo);
$result = $cacheConfig->getCacheTypeFrontendId($cacheType);
}
if (!$result) {
if (isset($this->_typeFrontendMap[$cacheType])) {
$result = $this->_typeFrontendMap[$cacheType];
} else {
$result = \Magento\Framework\App\Cache\Frontend\Pool::DEFAULT_FRONTEND_ID;
}
}
return $result;
}
示例5: __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->getSegment('resource') as $resourceName => $resourceData) {
if (!isset($resourceData['connection'])) {
throw new \InvalidArgumentException('Invalid initial resource configuration');
}
$this->_connectionNames[$resourceName] = $resourceData['connection'];
}
}
示例6: 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->getSegment(ConfigSegment::SEGMENT_KEY) ?: [];
}
}
示例7: deselectDisabledModules
/**
* Marks modules that are disabled in deploymentConfig as unselected.
*
* @return void
*/
private function deselectDisabledModules()
{
$existingModules = $this->deploymentConfig->getSegment(ModuleDeployment::CONFIG_KEY);
if (isset($existingModules)) {
foreach ($existingModules as $module => $value) {
if (!$value) {
$this->allModules[$module]['selected'] = false;
}
}
}
}
示例8: 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->getSegment(DbConfig::CONFIG_KEY);
if (null === $dbInfo) {
return false;
}
$dbConfig = new DbConfig($dbInfo);
$connectionConfig = $dbConfig->getConnection($connectionName);
if ($connectionConfig) {
$connection = $this->_connectionFactory->create($connectionConfig);
}
if (empty($connection)) {
return false;
}
$this->_connections[$connectionName] = $connection;
return $connection;
}
示例9: loadConfigData
/**
* Loads configuration data only
*
* @return void
*/
private function loadConfigData()
{
if (null === $this->configData) {
$this->configData = $this->config->getSegment(ModuleList\DeploymentConfig::CONFIG_KEY);
}
}
示例10: assertDbAccessible
/**
* Validates that MySQL is accessible and MySQL version is supported
*
* @return void
*/
private function assertDbAccessible()
{
$segment = $this->deploymentConfig->getSegment(DbConfig::CONFIG_KEY);
$dbConfig = new DbConfig($segment);
$config = $dbConfig->getConnection(\Magento\Framework\App\Resource\Config::DEFAULT_SETUP_CONNECTION);
$this->checkDatabaseConnection($config[DbConfig::KEY_NAME], $config[DbConfig::KEY_HOST], $config[DbConfig::KEY_USER], $config[DbConfig::KEY_PASS]);
if (isset($config[DbConfig::KEY_PREFIX])) {
$this->checkDatabaseTablePrefix($config[DbConfig::KEY_PREFIX]);
}
}
示例11: getDbInstance
/**
* Retrieve the database adapter instance
*
* @return \Magento\TestFramework\Db\AbstractDb
*/
public function getDbInstance()
{
if (null === $this->_db) {
if ($this->isInstalled()) {
$deploymentConfig = new DeploymentConfig(new \Magento\Framework\App\DeploymentConfig\Reader($this->dirList), []);
$dbConfig = new DbConfig($deploymentConfig->getSegment(DbConfig::CONFIG_KEY));
$dbInfo = $dbConfig->getConnection('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_pass'];
$dbName = $installConfig['db_name'];
}
$this->_db = new Db\Mysql($host, $user, $password, $dbName, $this->getTempDir(), $this->_shell);
}
return $this->_db;
}