/** * Parse from path * * Parses a given file according to the specified options * * @param string $path Path to file * @param array $options Parsing options * @return array */ public function parseFromPath($path, array $options = []) { $result = []; $this->validatePath($path); // Overwrite defaults if (!empty($options)) { $this->options = $options; } $reader = new IniReader(); $result = $reader->readFile($path); return $result; }
/** * Merge provided config with config from file * * @throws IniReadingException */ public function getConfig(InputInterface $input) { if (!$this->config) { $iniReader = new IniReader(); try { $config = $iniReader->readFile($this->getAppConfigPath()); $this->config = $config['default']; foreach ($input->getOptions() as $option => $value) { if ($value) { $this->config[$option] = $value; } } } catch (IniReadingException $e) { $this->getOutput()->writeln('<error>Unable to read config. Try running `configure` again.</error>'); } } return $this->config; }
public function dropDatabase($dbName = null) { $dbName = $dbName ?: $this->dbName ?: self::getConfig()->database_tests['dbname']; $this->log("Dropping database '{$dbName}'..."); $iniReader = new IniReader(); $config = $iniReader->readFile(PIWIK_INCLUDE_PATH . '/config/config.ini.php'); $originalDbName = $config['database']['dbname']; if ($dbName == $originalDbName && $dbName != 'piwik_tests') { // santity check throw new \Exception("Trying to drop original database '{$originalDbName}'. Something's wrong w/ the tests."); } try { DbHelper::dropDatabase($dbName); } catch (Exception $e) { printf("Dropping database %s failed: %s\n", $dbName, $e->getMessage()); } }
/** * Reloads settings from disk. */ public function reload($defaultSettingsFiles = array(), $userSettingsFile = null) { if (!empty($defaultSettingsFiles) || !empty($userSettingsFile)) { $this->resetSettingsChain($defaultSettingsFiles, $userSettingsFile); } $reader = new IniReader(); foreach ($this->settingsChain as $file => $ignore) { if (is_readable($file)) { try { $contents = $reader->readFile($file); $this->settingsChain[$file] = $this->decodeValues($contents); } catch (IniReadingException $ex) { throw new IniReadingException('Unable to read INI file {' . $file . '}: ' . $ex->getMessage() . "\n Your host may have disabled parse_ini_file()."); } $this->decodeValues($this->settingsChain[$file]); } } $this->mergedSettings = $this->mergeFileSettings(); }
/** * Reloads settings from disk. */ public function reload($defaultSettingsFiles = array(), $userSettingsFile = null) { if (!empty($defaultSettingsFiles) || !empty($userSettingsFile)) { $this->resetSettingsChain($defaultSettingsFiles, $userSettingsFile); } $reader = new IniReader(); foreach ($this->settingsChain as $file => $ignore) { if (is_readable($file)) { try { $contents = $reader->readFile($file); $this->settingsChain[$file] = $this->decodeValues($contents); } catch (IniReadingException $ex) { $message = Piwik::translate('General_ExceptionUnreadableFileDisabledMethod', array($file, "parse_ini_file()")); throw new IniReadingException($message, $code = 0, $ex); } } } $this->mergedSettings = $this->mergeFileSettings(); }
public function setUp() { $iniReader = new IniReader(); $this->globalConfig = $iniReader->readFile(PIWIK_PATH_TEST_TO_ROOT . '/config/global.ini.php'); parent::setUp(); }
/** * Reloads settings from disk. */ public function reload($defaultSettingsFiles = array(), $userSettingsFile = null) { if (!empty($defaultSettingsFiles) || !empty($userSettingsFile)) { $this->resetSettingsChain($defaultSettingsFiles, $userSettingsFile); } $reader = new IniReader(); foreach ($this->settingsChain as $file => $ignore) { if (is_readable($file)) { try { $contents = $reader->readFile($file); $this->settingsChain[$file] = $this->decodeValues($contents); } catch (IniReadingException $ex) { throw new IniReadingException('Unable to read INI file {' . $file . '}: ' . $ex->getMessage() . "\n Your host may have disabled parse_ini_file()."); } $this->decodeValues($this->settingsChain[$file]); } } $merged = $this->mergeFileSettings(); // remove reference to $this->settingsChain... otherwise dump() or compareElements() will never notice a difference // on PHP 7+ as they would be always equal $this->mergedSettings = $this->copy($merged); }
public function readConfig() { $reader = new IniReader(); $this->config = $reader->readFile($this->configFilename); }