Commaaa2
This commit is contained in:
@@ -90,6 +90,20 @@ class FilesystemManager implements FactoryContract
|
||||
return $this->disks[$name] = $this->get($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build an on-demand disk.
|
||||
*
|
||||
* @param string|array $config
|
||||
* @return \Illuminate\Contracts\Filesystem\Filesystem
|
||||
*/
|
||||
public function build($config)
|
||||
{
|
||||
return $this->resolve('ondemand', is_array($config) ? $config : [
|
||||
'driver' => 'local',
|
||||
'root' => $config,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt to get the disk from the local cache.
|
||||
*
|
||||
@@ -105,13 +119,14 @@ class FilesystemManager implements FactoryContract
|
||||
* Resolve the given disk.
|
||||
*
|
||||
* @param string $name
|
||||
* @param array|null $config
|
||||
* @return \Illuminate\Contracts\Filesystem\Filesystem
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
protected function resolve($name)
|
||||
protected function resolve($name, $config = null)
|
||||
{
|
||||
$config = $this->getConfig($name);
|
||||
$config = $config ?? $this->getConfig($name);
|
||||
|
||||
if (empty($config['driver'])) {
|
||||
throw new InvalidArgumentException("Disk [{$name}] does not have a configured driver.");
|
||||
@@ -125,11 +140,11 @@ class FilesystemManager implements FactoryContract
|
||||
|
||||
$driverMethod = 'create'.ucfirst($name).'Driver';
|
||||
|
||||
if (method_exists($this, $driverMethod)) {
|
||||
return $this->{$driverMethod}($config);
|
||||
} else {
|
||||
if (! method_exists($this, $driverMethod)) {
|
||||
throw new InvalidArgumentException("Driver [{$name}] is not supported.");
|
||||
}
|
||||
|
||||
return $this->{$driverMethod}($config);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -243,7 +258,7 @@ class FilesystemManager implements FactoryContract
|
||||
{
|
||||
$cache = Arr::pull($config, 'cache');
|
||||
|
||||
$config = Arr::only($config, ['visibility', 'disable_asserts', 'url']);
|
||||
$config = Arr::only($config, ['visibility', 'disable_asserts', 'url', 'temporary_url']);
|
||||
|
||||
if ($cache) {
|
||||
$adapter = new CachedAdapter($adapter, $this->createCacheStore($cache));
|
||||
@@ -326,7 +341,7 @@ class FilesystemManager implements FactoryContract
|
||||
*/
|
||||
public function getDefaultCloudDriver()
|
||||
{
|
||||
return $this->app['config']['filesystems.cloud'];
|
||||
return $this->app['config']['filesystems.cloud'] ?? 's3';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -344,6 +359,19 @@ class FilesystemManager implements FactoryContract
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disconnect the given disk and remove from local cache.
|
||||
*
|
||||
* @param string|null $name
|
||||
* @return void
|
||||
*/
|
||||
public function purge($name = null)
|
||||
{
|
||||
$name = $name ?? $this->getDefaultDriver();
|
||||
|
||||
unset($this->disks[$name]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a custom driver creator Closure.
|
||||
*
|
||||
@@ -358,6 +386,19 @@ class FilesystemManager implements FactoryContract
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the application instance used by the manager.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Foundation\Application $app
|
||||
* @return $this
|
||||
*/
|
||||
public function setApplication($app)
|
||||
{
|
||||
$this->app = $app;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dynamically call the default driver instance.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user