public function testGet() { $config = new Config(); $this->assertFalse($config->has('setting')); $this->assertNull($config->get('setting')); $config->set('setting', 'value'); $this->assertEquals('value', $config->get('setting')); $fallback = new Config(['fallback_setting' => 'fallback_value']); $config->setFallback($fallback); $this->assertEquals('fallback_value', $config->get('fallback_setting')); }
/** * Handle. * * @param string $path * @param string $localFilePath * @param array $config * @return bool */ public function handle($path, $localFilePath, array $config = []) { if (!method_exists($this->filesystem, 'getAdapter')) { return false; } if (!method_exists($this->filesystem->getAdapter(), 'putFile')) { return false; } $config = new Config($config); if (method_exists($this->filesystem, 'getConfig')) { $config->setFallback($this->filesystem->getConfig()); } return (bool) $this->filesystem->getAdapter()->putFile($path, $localFilePath, $config); }
/** * PdoAdapter constructor. * @param \PDO $db * @param Config $config */ public function __construct(\PDO $db, Config $config = null) { $this->db = $db; if ($config === null) { $config = new Config(); } $defaultPrefix = 'flysystem'; $config->setFallback(new Config(['table_prefix' => $defaultPrefix, 'enable_compression' => true, 'chunk_size' => 1048576, 'temp_dir' => sys_get_temp_dir(), 'disable_mysql_buffering' => true])); $this->config = $config; $tablePrefix = trim($this->config->get('table_prefix')); if ($tablePrefix == '') { $tablePrefix = $defaultPrefix; } $this->pathTable = "{$tablePrefix}_path"; $this->chunkTable = "{$tablePrefix}_chunk"; if ($config->get('disable_mysql_buffering')) { $this->db->setAttribute(\PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false); } }
/** * Convert a config array to a Config object with the correct fallback. * * @param array $config * * @return Config */ protected function prepareConfig(array $config) { $config = new Config($config); $config->setFallback($this->config); return $config; }
protected function defaultConfig() { $config = new Config(); $config->setFallback($this->filesystem->getConfig()); return $config; }