本文整理汇总了PHP中Magento\Framework\App\DeploymentConfig类的典型用法代码示例。如果您正苦于以下问题:PHP DeploymentConfig类的具体用法?PHP DeploymentConfig怎么用?PHP DeploymentConfig使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DeploymentConfig类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __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;
}
示例2: testRemoveModulesFromDeploymentConfig
public function testRemoveModulesFromDeploymentConfig()
{
$this->output->expects($this->atLeastOnce())->method('writeln');
$this->deploymentConfig->expects($this->once())->method('getConfigData')->willReturn(['moduleA' => 1, 'moduleB' => 1, 'moduleC' => 1, 'moduleD' => 1]);
$this->loader->expects($this->once())->method('load')->willReturn(['moduleC' => [], 'moduleD' => []]);
$this->writer->expects($this->once())->method('saveConfig')->with([ConfigFilePool::APP_CONFIG => [ConfigOptionsListConstants::KEY_MODULES => ['moduleC' => 1, 'moduleD' => 1]]]);
$this->moduleRegistryUninstaller->removeModulesFromDeploymentConfig($this->output, ['moduleA', 'moduleB']);
}
示例3: __construct
/**
* @param \Magento\Backend\App\Config $config
* @param DeploymentConfig $deploymentConfig
* @param ScopeConfigInterface $configInterface
*/
public function __construct(
\Magento\Backend\App\Config $config,
DeploymentConfig $deploymentConfig,
ScopeConfigInterface $configInterface
) {
$this->config = $config;
$this->defaultFrontName = $deploymentConfig->get(ConfigOptionsList::CONFIG_PATH_BACKEND_FRONTNAME);
$this->configInterface = $configInterface;
}
示例4: __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'];
}
}
示例5: __construct
/**
* Constructor
*
* @param SaveHandlerFactory $saveHandlerFactory
* @param DeploymentConfig $deploymentConfig
* @param string $default
*/
public function __construct(SaveHandlerFactory $saveHandlerFactory, DeploymentConfig $deploymentConfig, $default = self::DEFAULT_HANDLER)
{
$saveMethod = $deploymentConfig->get(\Magento\Framework\Session\Config::PARAM_SESSION_SAVE_METHOD);
try {
$adapter = $saveHandlerFactory->create($saveMethod);
} catch (SessionException $e) {
$adapter = $saveHandlerFactory->create($default);
}
$this->saveHandlerAdapter = $adapter;
}
示例6: testCheckUpdate
/**
* @dataProvider checkUpdateDataProvider
* @param bool $callInbox
* @param string $curlRequest
*/
public function testCheckUpdate($callInbox, $curlRequest)
{
$mockName = 'Test Product Name';
$mockVersion = '0.0.0';
$mockEdition = 'Test Edition';
$mockUrl = 'http://test-url';
$this->productMetadata->expects($this->once())->method('getName')->willReturn($mockName);
$this->productMetadata->expects($this->once())->method('getVersion')->willReturn($mockVersion);
$this->productMetadata->expects($this->once())->method('getEdition')->willReturn($mockEdition);
$this->urlBuilder->expects($this->once())->method('getUrl')->with('*/*/*')->willReturn($mockUrl);
$configValues = ['timeout' => 2, 'useragent' => $mockName . '/' . $mockVersion . ' (' . $mockEdition . ')', 'referer' => $mockUrl];
$lastUpdate = 0;
$this->cacheManager->expects($this->once())->method('load')->will($this->returnValue($lastUpdate));
$this->curlFactory->expects($this->at(0))->method('create')->will($this->returnValue($this->curl));
$this->curl->expects($this->once())->method('setConfig')->with($configValues)->willReturnSelf();
$this->curl->expects($this->once())->method('read')->will($this->returnValue($curlRequest));
$this->backendConfig->expects($this->at(0))->method('getValue')->will($this->returnValue('1'));
$this->backendConfig->expects($this->once())->method('isSetFlag')->will($this->returnValue(false));
$this->backendConfig->expects($this->at(1))->method('getValue')->will($this->returnValue('http://feed.magento.com'));
$this->deploymentConfig->expects($this->once())->method('get')->with(ConfigOptionsListConstants::CONFIG_PATH_INSTALL_DATE)->will($this->returnValue('Sat, 6 Sep 2014 16:46:11 UTC'));
if ($callInbox) {
$this->inboxFactory->expects($this->once())->method('create')->will($this->returnValue($this->inboxModel));
$this->inboxModel->expects($this->once())->method('parse')->will($this->returnSelf());
} else {
$this->inboxFactory->expects($this->never())->method('create');
$this->inboxModel->expects($this->never())->method('parse');
}
$this->feed->checkUpdate();
}
示例7: execute
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$notification = 'setup-cron: Please check var/log/update.log for execution summary.';
if (!$this->deploymentConfig->isAvailable()) {
$output->writeln($notification);
$this->status->add('Magento is not installed.', \Psr\Log\LogLevel::INFO);
return \Magento\Framework\Console\Cli::RETURN_SUCCESS;
}
if (!$this->checkRun()) {
$output->writeln($notification);
// we must have an exit code higher than zero to indicate something was wrong
return \Magento\Framework\Console\Cli::RETURN_FAILURE;
}
try {
$this->status->toggleUpdateInProgress();
} catch (\RuntimeException $e) {
$this->status->add($e->getMessage(), \Psr\Log\LogLevel::ERROR);
$output->writeln($notification);
// we must have an exit code higher than zero to indicate something was wrong
return \Magento\Framework\Console\Cli::RETURN_FAILURE;
}
$returnCode = $this->executeJobsFromQueue();
if ($returnCode != \Magento\Framework\Console\Cli::RETURN_SUCCESS) {
$output->writeln($notification);
}
return $returnCode;
}
示例8: execute
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
if (!$this->deploymentConfig->isAvailable() && ($input->getOption(self::INPUT_KEY_MEDIA) || $input->getOption(self::INPUT_KEY_DB))) {
$output->writeln("<info>No information is available: the Magento application is not installed.</info>");
return;
}
try {
$inputOptionProvided = false;
$output->writeln('<info>Enabling maintenance mode</info>');
$this->maintenanceMode->set(true);
$time = time();
$backupHandler = $this->backupRollbackFactory->create($output);
if ($input->getOption(self::INPUT_KEY_CODE)) {
$backupHandler->codeBackup($time);
$inputOptionProvided = true;
}
if ($input->getOption(self::INPUT_KEY_MEDIA)) {
$backupHandler->codeBackup($time, Factory::TYPE_MEDIA);
$inputOptionProvided = true;
}
if ($input->getOption(self::INPUT_KEY_DB)) {
$backupHandler->dbBackup($time);
$inputOptionProvided = true;
}
if (!$inputOptionProvided) {
throw new \InvalidArgumentException('Not enough information provided to take backup.');
}
} catch (\Exception $e) {
$output->writeln('<error>' . $e->getMessage() . '</error>');
} finally {
$output->writeln('<info>Disabling maintenance mode</info>');
$this->maintenanceMode->set(false);
}
}
示例9: execute
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
if (!$this->deploymentConfig->isAvailable() && ($input->getOption(self::INPUT_KEY_MEDIA_BACKUP_FILE) || $input->getOption(self::INPUT_KEY_DB_BACKUP_FILE))) {
$output->writeln("<info>No information is available: the Magento application is not installed.</info>");
// we must have an exit code higher than zero to indicate something was wrong
return \Magento\Framework\Console\Cli::RETURN_FAILURE;
}
$returnValue = \Magento\Framework\Console\Cli::RETURN_SUCCESS;
try {
$output->writeln('<info>Enabling maintenance mode</info>');
$this->maintenanceMode->set(true);
$helper = $this->getHelper('question');
$question = new ConfirmationQuestion('<info>You are about to remove current code and/or database tables. Are you sure?[y/N]<info>', false);
if (!$helper->ask($input, $output, $question) && $input->isInteractive()) {
return \Magento\Framework\Console\Cli::RETURN_FAILURE;
}
$this->doRollback($input, $output);
$output->writeln('<info>Please set file permission of bin/magento to executable</info>');
} catch (\Exception $e) {
$output->writeln('<error>' . $e->getMessage() . '</error>');
// we must have an exit code higher than zero to indicate something was wrong
$returnValue = \Magento\Framework\Console\Cli::RETURN_FAILURE;
} finally {
$output->writeln('<info>Disabling maintenance mode</info>');
$this->maintenanceMode->set(false);
}
return $returnValue;
}
示例10: testExecuteNoOptions
public function testExecuteNoOptions()
{
$this->deploymentConfig->expects($this->once())->method('isAvailable')->will($this->returnValue(false));
$this->tester->execute([]);
$expected = 'Enabling maintenance mode' . PHP_EOL . 'Not enough information provided to take backup.' . PHP_EOL . 'Disabling maintenance mode' . PHP_EOL;
$this->assertSame($expected, $this->tester->getDisplay());
}
示例11: execute
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
if (!$this->deploymentConfig->isAvailable()) {
$output->writeln("<info>No information is available: the Magento application is not installed.</info>");
return;
}
/** @var DbVersionInfo $dbVersionInfo */
$dbVersionInfo = $this->objectManagerProvider->get()->get('Magento\\Framework\\Module\\DbVersionInfo');
$outdated = $dbVersionInfo->getDbVersionErrors();
if (!empty($outdated)) {
$output->writeln("<info>The module code base doesn't match the DB schema and data.</info>");
$versionParser = new VersionParser();
$codebaseUpdateNeeded = false;
foreach ($outdated as $row) {
if (!$codebaseUpdateNeeded && $row[DbVersionInfo::KEY_CURRENT] !== 'none') {
// check if module code base update is needed
$currentVersion = $versionParser->parseConstraints($row[DbVersionInfo::KEY_CURRENT]);
$requiredVersion = $versionParser->parseConstraints('>' . $row[DbVersionInfo::KEY_REQUIRED]);
if ($requiredVersion->matches($currentVersion)) {
$codebaseUpdateNeeded = true;
}
}
$output->writeln(sprintf("<info>%20s %10s: %11s -> %-11s</info>", $row[DbVersionInfo::KEY_MODULE], $row[DbVersionInfo::KEY_TYPE], $row[DbVersionInfo::KEY_CURRENT], $row[DbVersionInfo::KEY_REQUIRED]));
}
if ($codebaseUpdateNeeded) {
$output->writeln('<info>Some modules use code versions newer or older than the database. ' . "First update the module code, then run 'setup:upgrade'.</info>");
// we must have an exit code higher than zero to indicate something was wrong
return \Magento\Framework\Console\Cli::RETURN_FAILURE;
} else {
$output->writeln("<info>Run 'setup:upgrade' to update your DB schema and data.</info>");
}
} else {
$output->writeln('<info>All modules are up to date.</info>');
}
}
示例12: testExecuteNotInstalled
public function testExecuteNotInstalled()
{
$this->deploymentConfig->expects($this->once())->method('isAvailable')->will($this->returnValue(false));
$this->installerFactory->expects($this->never())->method('create');
$tester = new CommandTester($this->command);
$tester->execute([]);
$this->assertStringMatchesFormat("Store settings can't be saved because the Magento application is not installed.%w", $tester->getDisplay());
}
示例13: testExecuteNotInstalled
public function testExecuteNotInstalled()
{
$this->deploymentConfig->expects($this->once())->method('isAvailable')->will($this->returnValue(false));
$this->dbVersionInfo->expects($this->never())->method('getDbVersionErrors');
$tester = new CommandTester($this->command);
$tester->execute([]);
$this->assertStringMatchesFormat('No information is available: the Magento application is not installed.%w', $tester->getDisplay());
}
示例14: testExecuteNoConfig
public function testExecuteNoConfig()
{
$this->deploymentConfig->expects($this->once())->method('isAvailable')->will($this->returnValue(false));
$this->installerFactory->expects($this->never())->method('create');
$commandTester = new CommandTester(new DbDataUpgradeCommand($this->installerFactory, $this->deploymentConfig));
$commandTester->execute([]);
$this->assertStringMatchesFormat('No information is available: the application is not installed.%w', $commandTester->getDisplay());
}
示例15: testExecute
public function testExecute()
{
$this->deploymentConfig->expects($this->once())->method('get')->willReturn('admin_qw12er');
$commandTester = new CommandTester(new InfoAdminUriCommand($this->deploymentConfig));
$commandTester->execute([]);
$regexp = '/' . BackendFrontnameGenerator::ADMIN_AREA_PATH_PREFIX . '[a-z0-9]{1,' . BackendFrontnameGenerator::ADMIN_AREA_PATH_RANDOM_PART_LENGTH . '}/';
$this->assertRegExp($regexp, $commandTester->getDisplay(), 'Unexpected Backend Frontname pattern.');
}