| 1 |
<?php |
| 2 |
|
| 3 |
namespace League\Flysystem; |
| 4 |
|
| 5 |
/** |
| 6 |
* @internal |
| 7 |
*/ |
| 8 |
trait ConfigAwareTrait |
| 9 |
{ |
| 10 |
/** |
| 11 |
* @var Config |
| 12 |
*/ |
| 13 |
protected $config; |
| 14 |
|
| 15 |
/** |
| 16 |
* Set the config. |
| 17 |
* |
| 18 |
* @param Config|array|null $config |
| 19 |
*/ |
| 20 |
protected function setConfig($config) |
| 21 |
{ |
| 22 |
$this->config = $config ? Util::ensureConfig($config) : new Config; |
| 23 |
} |
| 24 |
|
| 25 |
/** |
| 26 |
* Get the Config. |
| 27 |
* |
| 28 |
* @return Config config object |
| 29 |
*/ |
| 30 |
public function getConfig() |
| 31 |
{ |
| 32 |
return $this->config; |
| 33 |
} |
| 34 |
|
| 35 |
/** |
| 36 |
* Convert a config array to a Config object with the correct fallback. |
| 37 |
* |
| 38 |
* @param array $config |
| 39 |
* |
| 40 |
* @return Config |
| 41 |
*/ |
| 42 |
protected function prepareConfig(array $config) |
| 43 |
{ |
| 44 |
$config = new Config($config); |
| 45 |
$config->setFallback($this->getConfig()); |
| 46 |
|
| 47 |
return $config; |
| 48 |
} |
| 49 |
} |
| 50 |
|