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')); }
/** * {@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>'); } }
/** * 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; }
/** * 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; }
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'); }
/** * 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; }
/** * 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; }
/** * @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; }
/** * 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); } }
/** * 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; }
/** * 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; }
/** * 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()); } }
/** * 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; }
/** * 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; }
/** * 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; }
/** * 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; }
/** @inheritdoc */ public function create($transactionName, $connectionName) { /** @var \Praxigento\Core\Transaction\Database\Def\Item $result */ $result = $this->_manObj->create(\Praxigento\Core\Transaction\Database\Def\Item::class); $result->setTransactionName($transactionName); $result->setConnectionName($connectionName); if ($transactionName != \Praxigento\Core\Transaction\Database\IManager::DEF_TRANSACTION || $connectionName != \Praxigento\Core\Transaction\Database\IManager::DEF_CONNECTION) { /* create new connection, don't use default connection/transaction */ /* 'db/connection/default' */ $cfgName = \Magento\Framework\Config\ConfigOptionsListConstants::CONFIG_PATH_DB_CONNECTIONS . '/' . $connectionName; /* {'host'=>'', 'dbname'=>'', 'username'=>'', 'password'=>'', 'model'=>'', 'engine'=>'', 'initStatements'=>'', 'active'=>''}*/ $cfgData = $this->_configDeployment->get($cfgName); /* @var \Magento\Framework\DB\Adapter\AdapterInterface $dba */ $conn = $this->_factoryConn->create($cfgData); $result->setConnection($conn); } return $result; }
/** * @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; }
/** * 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; }
/** * {@inheritdoc} */ public function createConfig(array $options, DeploymentConfig $deploymentConfig) { $configData = new ConfigData(ConfigFilePool::APP_CONFIG); if (isset($options[self::INPUT_KEY_CUSTOM_OPTION])) { $configData->set(self::CONFIG_PATH_CUSTOM_OPTION, $options[self::INPUT_KEY_CUSTOM_OPTION]); } elseif ($deploymentConfig->get(self::CONFIG_PATH_CUSTOM_OPTION) === null) { // set to default value if it is not already set in deployment configuration $configData->set(self::CONFIG_PATH_CUSTOM_OPTION, 'default custom value'); } return [$configData]; }
/** * Marks modules that are disabled in deploymentConfig as unselected. * * @return void */ private function deselectDisabledModules() { $existingModules = $this->deploymentConfig->get(ConfigOptionsListConstants::KEY_MODULES); if (isset($existingModules)) { foreach ($existingModules as $module => $value) { if (!$value) { $this->allModules[$module]['selected'] = false; } } } }
/** * {@inheritdoc} * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function createConfig(array $options, DeploymentConfig $deploymentConfig) { $configData = new ConfigData(ConfigFilePool::APP_ENV); if (!$deploymentConfig->get(self::CONFIG_PATH_BACKEND_FRONTNAME) && !isset($options[self::INPUT_KEY_BACKEND_FRONTNAME])) { $options[self::INPUT_KEY_BACKEND_FRONTNAME] = BackendFrontnameGenerator::generate(); } if (isset($options[self::INPUT_KEY_BACKEND_FRONTNAME])) { $configData->set(self::CONFIG_PATH_BACKEND_FRONTNAME, $options[self::INPUT_KEY_BACKEND_FRONTNAME]); } return [$configData]; }
/** * A private function to check database access and return appropriate error message in case of error * * @return string */ private function performDBCheck() { $errorLogMessage = ''; $dbInfo = $this->deploymentConfig->get(\Magento\Framework\Config\ConfigOptionsListConstants::CONFIG_PATH_DB_CONNECTION_DEFAULT); try { $this->dbValidator->checkDatabaseConnection($dbInfo[\Magento\Framework\Config\ConfigOptionsListConstants::KEY_NAME], $dbInfo[\Magento\Framework\Config\ConfigOptionsListConstants::KEY_HOST], $dbInfo[\Magento\Framework\Config\ConfigOptionsListConstants::KEY_USER], $dbInfo[\Magento\Framework\Config\ConfigOptionsListConstants::KEY_PASSWORD]); } catch (\Exception $e) { $errorLogMessage = $e->getMessage(); } return $errorLogMessage; }
/** * 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'); $configFilePool = \Magento\Mtf\ObjectManagerFactory::getObjectManager()->get('\\Magento\\Framework\\Config\\File\\ConfigFilePool'); $driverPool = \Magento\Mtf\ObjectManagerFactory::getObjectManager()->get('\\Magento\\Framework\\Filesystem\\DriverPool'); $reader = new Reader($dirList, $driverPool, $configFilePool); $deploymentConfig = new DeploymentConfig($reader); $host = $deploymentConfig->get(ConfigOptionsListConstants::CONFIG_PATH_DB_CONNECTION_DEFAULT . '/' . ConfigOptionsListConstants::KEY_HOST); $user = $deploymentConfig->get(ConfigOptionsListConstants::CONFIG_PATH_DB_CONNECTION_DEFAULT . '/' . ConfigOptionsListConstants::KEY_USER); $password = $deploymentConfig->get(ConfigOptionsListConstants::CONFIG_PATH_DB_CONNECTION_DEFAULT . '/' . ConfigOptionsListConstants::KEY_PASSWORD); $database = $deploymentConfig->get(ConfigOptionsListConstants::CONFIG_PATH_DB_CONNECTION_DEFAULT . '/' . ConfigOptionsListConstants::KEY_NAME); $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); } }
/** * @param \Magento\Framework\ValidatorFactory $validatorFactory * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Framework\Stdlib\StringUtils $stringHelper * @param \Magento\Framework\App\RequestInterface $request * @param Filesystem $filesystem * @param DeploymentConfig $deploymentConfig * @param string $scopeType * @param string $lifetimePath * @SuppressWarnings(PHPMD.NPathComplexity) */ public function __construct(\Magento\Framework\ValidatorFactory $validatorFactory, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Framework\Stdlib\StringUtils $stringHelper, \Magento\Framework\App\RequestInterface $request, Filesystem $filesystem, DeploymentConfig $deploymentConfig, $scopeType, $lifetimePath = self::XML_PATH_COOKIE_LIFETIME) { $this->_validatorFactory = $validatorFactory; $this->_scopeConfig = $scopeConfig; $this->_stringHelper = $stringHelper; $this->_httpRequest = $request; $this->_scopeType = $scopeType; $this->lifetimePath = $lifetimePath; /** * Session path */ $savePath = $deploymentConfig->get(self::PARAM_SESSION_SAVE_PATH); if (!$savePath && !ini_get('session.save_path')) { $sessionDir = $filesystem->getDirectoryWrite(DirectoryList::SESSION); $savePath = $sessionDir->getAbsolutePath(); $sessionDir->create(); } if ($savePath) { $this->setSavePath($savePath); } /** * Session cache limiter */ $cacheLimiter = $deploymentConfig->get(self::PARAM_SESSION_CACHE_LIMITER); if ($cacheLimiter) { $this->setOption('session.cache_limiter', $cacheLimiter); } /** * Cookie settings: lifetime, path, domain, httpOnly. These govern settings for the session cookie. */ $this->configureCookieLifetime(); $path = $this->_scopeConfig->getValue(self::XML_PATH_COOKIE_PATH, $this->_scopeType); $path = empty($path) ? $this->_httpRequest->getBasePath() : $path; $this->setCookiePath($path, $this->_httpRequest->getBasePath()); $domain = $this->_scopeConfig->getValue(self::XML_PATH_COOKIE_DOMAIN, $this->_scopeType); $domain = empty($domain) ? $this->_httpRequest->getHttpHost() : $domain; $this->setCookieDomain((string) $domain, $this->_httpRequest->getHttpHost()); $this->setCookieHttpOnly($this->_scopeConfig->getValue(self::XML_PATH_COOKIE_HTTPONLY, $this->_scopeType)); $secureURL = $this->_scopeConfig->getValue('web/secure/base_url', $this->_scopeType); $unsecureURL = $this->_scopeConfig->getValue('web/unsecure/base_url', $this->_scopeType); $isFullySecuredURL = $secureURL == $unsecureURL; $this->setCookieSecure($isFullySecuredURL && $this->_httpRequest->isSecure()); }
/** * Constructor * * @param SaveHandlerFactory $saveHandlerFactory * @param DeploymentConfig $deploymentConfig * @param string $default */ public function __construct(SaveHandlerFactory $saveHandlerFactory, DeploymentConfig $deploymentConfig, $default = self::DEFAULT_HANDLER) { /** * Session handler * * Save handler may be set to custom value in deployment config, which will override everything else. * Otherwise, try to read PHP settings for session.save_handler value. Otherwise, use 'files' as default. */ $defaultSaveHandler = ini_get('session.save_handler') ?: SaveHandlerInterface::DEFAULT_HANDLER; $saveMethod = $deploymentConfig->get(Config::PARAM_SESSION_SAVE_METHOD, $defaultSaveHandler); $this->setSaveHandler($saveMethod); try { $connection = $saveHandlerFactory->create($saveMethod); } catch (SessionException $e) { $connection = $saveHandlerFactory->create($default); $this->setSaveHandler($default); } $this->saveHandlerAdapter = $connection; }
/** * 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.'; } /** * By the time the command is able to execute, the Object Management configuration is already contaminated * by old config info, and it's too late to just clear the files in code. * * TODO: reconfigure OM in runtime so DI resources can be cleared after command launches * */ $path = $this->directoryList->getPath(DirectoryList::DI); if ($this->fileDriver->isExists($path)) { $messages[] = "DI configuration must be cleared before running compiler. Please delete '{$path}'."; } return $messages; }
/** * Run the readiness check * * @return bool */ public function runReadinessCheck() { $resultJsonRawData = [self::KEY_READINESS_CHECKS => []]; // checks PHP $phpVersionCheckResult = $this->phpReadinessCheck->checkPhpVersion(); $phpExtensionsCheckResult = $this->phpReadinessCheck->checkPhpExtensions(); $phpSettingsCheckResult = $this->phpReadinessCheck->checkPhpSettings(); $resultJsonRawData[self::KEY_PHP_CHECKS][self::KEY_PHP_VERSION_VERIFIED] = $phpVersionCheckResult; $resultJsonRawData[self::KEY_PHP_CHECKS][self::KEY_PHP_EXTENSIONS_VERIFIED] = $phpExtensionsCheckResult; $resultJsonRawData[self::KEY_PHP_CHECKS][self::KEY_PHP_SETTINGS_VERIFIED] = $phpSettingsCheckResult; // checks Database privileges $success = true; $errorMsg = ''; $write = $this->filesystem->getDirectoryWrite(DirectoryList::VAR_DIR); $dbInfo = $this->deploymentConfig->get(ConfigOptionsListConstants::CONFIG_PATH_DB_CONNECTION_DEFAULT); try { $this->dbValidator->checkDatabaseConnection($dbInfo[ConfigOptionsListConstants::KEY_NAME], $dbInfo[ConfigOptionsListConstants::KEY_HOST], $dbInfo[ConfigOptionsListConstants::KEY_USER], $dbInfo[ConfigOptionsListConstants::KEY_PASSWORD]); } catch (\Exception $e) { $success = false; $errorMsg .= $e->getMessage(); } if ($success) { $resultJsonRawData[self::KEY_READINESS_CHECKS][self::KEY_DB_WRITE_PERMISSION_VERIFIED] = true; } else { $resultJsonRawData[self::KEY_READINESS_CHECKS][self::KEY_DB_WRITE_PERMISSION_VERIFIED] = false; $resultJsonRawData[self::KEY_READINESS_CHECKS][self::KEY_ERROR] = $errorMsg; } // updates timestamp if ($write->isExist(self::SETUP_CRON_JOB_STATUS_FILE)) { $jsonData = json_decode($write->readFile(self::SETUP_CRON_JOB_STATUS_FILE), true); if (isset($jsonData[self::KEY_CURRENT_TIMESTAMP])) { $resultJsonRawData[self::KEY_LAST_TIMESTAMP] = $jsonData[self::KEY_CURRENT_TIMESTAMP]; } } $resultJsonRawData[self::KEY_CURRENT_TIMESTAMP] = time(); $resultJson = json_encode($resultJsonRawData, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); $write->writeFile(self::SETUP_CRON_JOB_STATUS_FILE, $resultJson); return $success; }
/** * @param \Magento\Framework\App\Helper\Context $context * @param \Magento\Store\Model\StoreManagerInterface $storeManager * @param DeploymentConfig $deploymentConfig */ public function __construct(\Magento\Framework\App\Helper\Context $context, \Magento\Store\Model\StoreManagerInterface $storeManager, DeploymentConfig $deploymentConfig) { parent::__construct($context); $this->_installDate = $deploymentConfig->get(ConfigOptionsListConstants::CONFIG_PATH_INSTALL_DATE); $this->_storeManager = $storeManager; }
/** * Retrieve the database adapter instance * * @return \Magento\TestFramework\Db\AbstractDb */ public function getDbInstance() { if (null === $this->_db) { if ($this->isInstalled()) { $configPool = new \Magento\Framework\Config\File\ConfigFilePool(); $driverPool = new \Magento\Framework\Filesystem\DriverPool(); $reader = new Reader($this->dirList, $driverPool, $configPool); $deploymentConfig = new DeploymentConfig($reader, []); $host = $deploymentConfig->get(ConfigOptionsListConstants::CONFIG_PATH_DB_CONNECTION_DEFAULT . '/' . ConfigOptionsListConstants::KEY_HOST); $user = $deploymentConfig->get(ConfigOptionsListConstants::CONFIG_PATH_DB_CONNECTION_DEFAULT . '/' . ConfigOptionsListConstants::KEY_USER); $password = $deploymentConfig->get(ConfigOptionsListConstants::CONFIG_PATH_DB_CONNECTION_DEFAULT . '/' . ConfigOptionsListConstants::KEY_PASSWORD); $dbName = $deploymentConfig->get(ConfigOptionsListConstants::CONFIG_PATH_DB_CONNECTION_DEFAULT . '/' . ConfigOptionsListConstants::KEY_NAME); } 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; }