Skip to content

Commit b872585

Browse files
committed
Allow filesystem provider config to be set from constructor
1 parent 94872ba commit b872585

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

src/DependencyInjection/CompilerPass/FlysystemCompilerPass.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@ public function process(ContainerBuilder $container): void
3434
$definition
3535
->setClass(Filesystem::class)
3636
->setFactory([new Reference(FilesystemProvider::class), 'getFilesystem'])
37-
->addArgument($attributes['alias']);
37+
->setArguments([
38+
$attributes['alias'],
39+
$attributes['config'] ?? []
40+
]);
3841
$serviceName = sprintf('api_components.filesystem.%s', $attributes['alias']);
3942
$container->setDefinition($serviceName, $definition);
4043
}

src/Flysystem/FilesystemProvider.php

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,14 @@ class FilesystemProvider
2525
{
2626
public const FILESYSTEM_ADAPTER_TAG = 'silverback.api_components.filesystem_adapter';
2727

28-
private ServiceLocator $adapters;
29-
30-
public function __construct(ServiceLocator $adapters)
31-
{
32-
$this->adapters = $adapters;
33-
}
28+
public function __construct(private readonly ServiceLocator $adapters)
29+
{}
3430

3531
/**
3632
* @throws RuntimeException
3733
*/
38-
public function getFilesystem(string $name): Filesystem
34+
public function getFilesystem(string $name, array $config = []): Filesystem
3935
{
40-
return new Filesystem($this->adapters->get($name));
36+
return new Filesystem($this->adapters->get($name), $config);
4137
}
4238
}

0 commit comments

Comments
 (0)