protected function processLocalFileSetting(array $local_setting_info) { $settings = []; $file_path = AgaviConfig::get('core.local_config_dir') . '/' . $local_setting_info['path']; if (!is_readable($file_path)) { throw new RuntimeError('Unable to read local config file at: ' . $file_path); } if ($local_setting_info['type'] === 'yaml') { $yaml_string = file_get_contents($file_path); if (!$yaml_string) { throw new Exception('Failed to read local configuration at: ' . $file_path); } try { $yaml_parser = new Parser(); $settings = $yaml_parser->parse($yaml_string); } catch (Exception $parse_error) { throw new RuntimeError('Failed to parse yaml for local config file: ' . $file_path . PHP_EOL . 'Error: ' . $parse_error->getMessage()); } } elseif ($local_setting_info['type'] === 'json') { $json_string = file_get_contents($file_path); if (!$json_string) { throw new Exception('Failed to read local configuration at: ' . $file_path); } $settings = json_decode($json_string, true); if (json_last_error() !== JSON_ERROR_NONE) { throw new RuntimeError('Failed to parse json from file "' . $file_path . '": ' . json_last_error_msg()); } } else { throw new RuntimeError('Only "yaml" or "json" are supported for "type" setting of local configs.'); } if (!isset($local_setting_info['settings']['flatten']) || $local_setting_info['settings']['flatten'] === true) { $settings = ArrayToolkit::flatten($settings); } return $settings; }
public function __toString() { return sprintf('STORED QUERY: SEARCH %s PARAMS %s %s %s', $this->name, http_build_query(ArrayToolkit::flatten($this->parameters), '', ', '), isset($this->limit) ? 'LIMIT ' . $this->limit : '', isset($this->offset) ? 'OFFSET ' . $this->offset : ''); }
public function testFlatten() { $this->assertSame(['foo.bar' => 42], ArrayToolkit::flatten(['foo' => ['bar' => 42]])); }
public function __toString() { return sprintf('CUSTOM QUERY: SEARCH %s PARAMS %s %s %s', substr(static::CLASS, strrpos(static::CLASS, '\\') + 1), http_build_query(ArrayToolkit::flatten($this->parameters), '', ', '), isset($this->limit) ? 'LIMIT ' . $this->limit : '', isset($this->offset) ? 'OFFSET ' . $this->offset : ''); }