Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 30 additions & 26 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 2 additions & 16 deletions src/ConfigProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,11 @@
final class ConfigProvider
{
public const NAMED_ADAPTER_KEY = 'adapters';
public function __invoke(): array
{
return [
'dependencies' => $this->getDependencies(),
Adapter\AdapterInterface::class => $this->getConfig(),
];
}

public function getConfig(): array
public function __invoke(): array
{
// supported configuration structure
return [
// Adapter\Adapter::class => [],
// Adapter\AdapterInterface::class => [],
// self::NAMED_ADAPTER_KEY => [
// Adapter\Adapter::class => [],
// Adapter\AdapterInterface::class => [],
// 'Custom\Name' => [],
// ],
'dependencies' => $this->getDependencies(),
];
}

Expand Down
9 changes: 1 addition & 8 deletions src/Container/AdapterInterfaceFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public function __invoke(
'Container is missing a config service'
);
}

$config = $container->get('config') ?? [];
$adapterConfig = $config[AdapterInterface::class] ?? $config[Adapter::class] ?? [];

Expand All @@ -43,14 +44,6 @@ public function __invoke(
/** @var class-string<DriverInterface>|class-string<PdoDriverInterface>|null $driverClass */
$driverClass = $adapterConfig['driver'] ?? null;

if ($driverClass === null || ! $container->has($driverClass)) {
throw ContainerException::forService(
AdapterInterface::class,
self::class,
'Invalid or missing driver provided for ' . $requestedName
);
}

/** @var DriverInterface|PdoDriverInterface $driver */
$driver = $container->build($driverClass, $adapterConfig);

Expand Down
3 changes: 1 addition & 2 deletions test/unit/ConfigProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ class ConfigProviderTest extends TestCase
* }
* */
private array $config = [
Adapter\AdapterInterface::class => [],
'dependencies' => [
'dependencies' => [
'abstract_factories' => [
Container\AbstractAdapterInterfaceFactory::class,
],
Expand Down