本文整理汇总了PHP中Magento\Framework\App\DeploymentConfig::get方法的典型用法代码示例。如果您正苦于以下问题:PHP DeploymentConfig::get方法的具体用法?PHP DeploymentConfig::get怎么用?PHP DeploymentConfig::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\App\DeploymentConfig
的用法示例。
在下文中一共展示了DeploymentConfig::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$value = $this->deploymentConfig->get(ConfigOptionsList::CONFIG_PATH_CUSTOM_OPTION);
if ($value) {
$output->writeln('<info>The custom deployment configuration value is ' . $value . '</info>');
} else {
$output->writeln('<info>The custom deployment configuration value is not set.</info>');
}
}
示例2: toOptionArray
/**
* Returns list of available resources
*
* @return array
*/
public function toOptionArray()
{
$resourceOptions = [];
$resourceConfig = $this->deploymentConfig->get(ConfigOptionsListConstants::KEY_RESOURCE);
if (null !== $resourceConfig) {
foreach (array_keys($resourceConfig) as $resourceName) {
$resourceOptions[] = ['value' => $resourceName, 'label' => $resourceName];
}
sort($resourceOptions);
reset($resourceOptions);
}
return $resourceOptions;
}
示例3: getUris
/**
* Get cache servers' Uris
*
* @return Uri[]
*/
public function getUris()
{
$servers = [];
$configuredHosts = $this->config->get(ConfigOptionsListConstants::CONFIG_PATH_CACHE_HOSTS);
if (null == $configuredHosts) {
$httpHost = $this->request->getHttpHost();
$servers[] = $httpHost ? UriFactory::factory('')->setHost($httpHost)->setPort(self::DEFAULT_PORT)->setScheme('http') : UriFactory::factory($this->urlBuilder->getUrl('*', ['_nosid' => true]))->setScheme('http')->setPath(null)->setQuery(null);
} else {
foreach ($configuredHosts as $host) {
$servers[] = UriFactory::factory('')->setHost($host['host'])->setPort(isset($host['port']) ? $host['port'] : self::DEFAULT_PORT)->setScheme('http');
}
}
return $servers;
}
示例4: addDeploymentInfo
protected function addDeploymentInfo()
{
$this->infos['Application Mode'] = $this->deploymentConfig->get(AppState::PARAM_MODE);
$this->infos['Session'] = $this->deploymentConfig->get('session/save');
$this->infos['Crypt Key'] = $this->deploymentConfig->get('crypt/key');
$this->infos['Install Date'] = $this->deploymentConfig->get('install/date');
}
示例5: getTablePrefix
/**
* Get table prefix
*
* @return string
*/
private function getTablePrefix()
{
if (null === $this->_tablePrefix) {
$this->_tablePrefix = (string) $this->deploymentConfig->get(self::PARAM_TABLE_PREFIX);
}
return $this->_tablePrefix;
}
示例6: getAvailableOptions
/**
* Gets available config options
*
* @return AbstractConfigOption[]
*/
public function getAvailableOptions()
{
/** @var AbstractConfigOption[] $optionCollection */
$optionCollection = [];
$optionLists = $this->collector->collectOptionsLists();
foreach ($optionLists as $optionList) {
$optionCollection = array_merge($optionCollection, $optionList->getOptions());
}
foreach ($optionCollection as $option) {
$currentValue = $this->deploymentConfig->get($option->getConfigPath());
if ($currentValue !== null) {
$option->setDefault();
}
}
return $optionCollection;
}
示例7: __construct
/**
* @param \Magento\Framework\Math\Random $randomGenerator
* @param DeploymentConfig $deploymentConfig
*/
public function __construct(\Magento\Framework\Math\Random $randomGenerator, DeploymentConfig $deploymentConfig)
{
$this->randomGenerator = $randomGenerator;
// load all possible keys
$this->keys = preg_split('/\\s+/s', trim($deploymentConfig->get(self::PARAM_CRYPT_KEY)));
$this->keyVersion = count($this->keys) - 1;
}
示例8: loadConfigData
/**
* Loads configuration data only
*
* @return void
*/
private function loadConfigData()
{
$this->config->resetData();
if (null === $this->configData && null !== $this->config->get(ConfigOptionsListConstants::KEY_MODULES)) {
$this->configData = $this->config->get(ConfigOptionsListConstants::KEY_MODULES);
}
}
示例9: getTablePrefix
/**
* Get table prefix
*
* @return string
*/
private function getTablePrefix()
{
if (null === $this->_tablePrefix) {
$this->_tablePrefix = (string) $this->deploymentConfig->get(ConfigOptionsList::CONFIG_PATH_DB_PREFIX);
}
return $this->_tablePrefix;
}
示例10: checkUpdate
/**
* Check feed for modification
*
* @return $this
*/
public function checkUpdate()
{
if ($this->getFrequency() + $this->getLastUpdate() > time()) {
return $this;
}
$feedData = [];
$feedXml = $this->getFeedData();
$installDate = strtotime($this->_deploymentConfig->get(ConfigOptionsListConstants::CONFIG_PATH_INSTALL_DATE));
if ($feedXml && $feedXml->channel && $feedXml->channel->item) {
foreach ($feedXml->channel->item as $item) {
if ($installDate <= strtotime((string)$item->pubDate)) {
$feedData[] = [
'severity' => (int)$item->severity,
'date_added' => $this->getDate((string)$item->pubDate),
'title' => (string)$item->title,
'description' => (string)$item->description,
'url' => (string)$item->link,
];
}
}
if ($feedData) {
$this->_inboxFactory->create()->parse(array_reverse($feedData));
}
}
$this->setLastUpdate();
return $this;
}
示例11: __destruct
/**
* As per http://php.net/manual/en/language.oop5.decon.php:
* The destructor method will be called as soon as there are no other references to a particular object,
* or in any order during the shutdown sequence.
*
* As randomly tested accross the code, triggering exist and exceptions, the __destruct is called in cases of:
* - successful execution
* - exit() being called anywhere later on
* - exception being thrown anywhere later on
*
* This is a nice example of catching all query logs, which we populated first within the logStats method.
*
* Within the __destruct we initiate the new Database connection, from DB parameters read from config.
* This new DB connection is using the DB\Logger\Quiet so we don't fall into a loop of logging the
* SQL queries for SQL query logger :)
*
* This way, we agregated all of the individual query logs on request, and did one insertMultiple.
*/
public function __destruct()
{
try {
/**
* Note, logStats still executes. It is not possible to include DB read config in there as it executes
* right after first DB connection, and Magento does not have config value just yet.
* Thus we check here. Hopefully the performance impact is not too big within the logStats.
*/
if (!$this->helper->isQueryLogActive()) {
return;
}
$config = $this->deploymentConfig->get(\Magento\Framework\Config\ConfigOptionsListConstants::CONFIG_PATH_DB_CONNECTION_DEFAULT);
$connection = new \Magento\Framework\Model\ResourceModel\Type\Db\Pdo\Mysql(new \Magento\Framework\Stdlib\StringUtils(), new \Magento\Framework\Stdlib\DateTime(), $config);
/*
* Here we init the new DB connection with
* Magento config and directly set the dummy Quiet logger to it.
*/
$connection = $connection->getConnection(new \Magento\Framework\DB\Logger\Quiet());
$uniqueId = $this->helper->getHttpRequestUniqueId();
$logCallStack = $this->helper->getQueryLogCallStack();
$logQueryTime = $this->helper->getQueryLogQueryTime();
$logAllQueries = $this->helper->getQueryLogAllQueries();
$logQueryChunks = $this->helper->getQueryLogQueryChunks();
$this->queryLogs = array_map(create_function('$arr', '$arr["request_id"] = "' . $uniqueId . '"; return $arr;'), $this->queryLogs);
$queryLogChunks = array_chunk($this->queryLogs, $logQueryChunks);
/* Breaks in between 80 & 90 */
foreach ($queryLogChunks as $queryLogChunk) {
if (!$logCallStack) {
$queryLogChunk = array_map(create_function('$arr', 'unset($arr["backtrace"]); return $arr;'), $queryLogChunk);
}
$queryLogChunk = array_map(create_function('$arr', 'unset($arr["backtrace"]); return $arr;'), $queryLogChunk);
if ($logQueryTime && !$logAllQueries) {
$queryLogChunk = array_map(create_function('$arr', 'if($arr["time"] >= ' . $logQueryTime . ') { return $arr; }'), $queryLogChunk);
}
/* @todo Exclude the foggyline_sentinel_query_log table from logging itself */
/* $queryLogChunk = array_map(create_function('$arr', 'if (!strstr($arr["sql"], "foggyline_sentinel_query_log")) { return $arr; }'), $queryLogChunk); */
if ($queryLogChunk = array_filter($queryLogChunk)) {
/* @todo There is a bug here, DB name is without possible prefix/suffix, needs proper handling */
$connection->insertMultiple('foggyline_sentinel_query_log', $queryLogChunk);
}
}
/**
CREATE TABLE `foggyline_sentinel_query_log` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`type` text,
`time` decimal(12,4) DEFAULT NULL,
`sql` text,
`bind` text,
`row_count` int(11) DEFAULT NULL,
`request_id` text,
`backtrace` text,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=81 DEFAULT CHARSET=utf8;
*/
} catch (\Exception $e) {
//Silently do nothing :)
//var_dump($e->getMessage());
}
}
示例12: createXFrameConfig
/**
* Creates x-frame-options header config data
*
* @return ConfigData
*/
public function createXFrameConfig()
{
$configData = new ConfigData(ConfigFilePool::APP_ENV);
if ($this->deploymentConfig->get(ConfigOptionsListConstants::CONFIG_PATH_X_FRAME_OPT) === null) {
$configData->set(ConfigOptionsListConstants::CONFIG_PATH_X_FRAME_OPT, 'SAMEORIGIN');
}
return $configData;
}
示例13: createResourceConfig
/**
* Creates resource config data
*
* @return ConfigData
*/
public function createResourceConfig()
{
$configData = new ConfigData(ConfigFilePool::APP_CONFIG);
if ($this->deploymentConfig->get(ConfigOptionsList::CONFIG_PATH_RESOURCE_DEFAULT_SETUP) === null) {
$configData->set(ConfigOptionsList::CONFIG_PATH_RESOURCE_DEFAULT_SETUP, 'default');
}
return $configData;
}
示例14: createModeConfig
/**
* Create default entry for mode config option
*
* @return ConfigData
*/
public function createModeConfig()
{
$configData = new ConfigData(ConfigFilePool::APP_ENV);
if ($this->deploymentConfig->get(State::PARAM_MODE) === null) {
$configData->set(State::PARAM_MODE, State::MODE_DEFAULT);
}
return $configData;
}
示例15: checkEnvironment
/**
* Checks that application is installed and DI resources are cleared
*
* @return string[]
*/
private function checkEnvironment()
{
$messages = [];
$config = $this->deploymentConfig->get(ConfigOptionsListConstants::KEY_MODULES);
if (!$config) {
$messages[] = 'You cannot run this command because modules are not enabled. You can enable modules by' . ' running the \'module:enable --all\' command.';
}
return $messages;
}