Skip to content
Merged
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
11 changes: 8 additions & 3 deletions src/DI/RedisExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@ public function getConfigSchema(): Schema
'debug' => Expect::bool(false),
'serializer' => Expect::anyOf(Expect::string()),
'connection' => Expect::arrayOf(Expect::structure([
'autowired' => Expect::bool(null),
'uri' => Expect::anyOf(Expect::string()->dynamic(), Expect::listOf(Expect::string()->dynamic()))->default('tcp://127.0.0.1:6379'),
'options' => Expect::array(),
'storageAutowired' => Expect::bool(null),
'storageClass' => Expect::string()->default(RedisStorage::class),
'storage' => Expect::bool(false),
'sessions' => Expect::anyOf(
Expand All @@ -52,7 +54,7 @@ public function loadConfiguration(): void
$connections = [];

foreach ($config->connection as $name => $connection) {
$autowired = $name === 'default';
$autowired = $connection->autowired ?? ($name === 'default');

$client = $builder->addDefinition($this->prefix('connection.' . $name . '.client'))
->setType(ClientInterface::class)
Expand Down Expand Up @@ -86,7 +88,7 @@ public function beforeCompileStorage(): void
$storages = 0;

foreach ($config->connection as $name => $connection) {
$autowired = $name === 'default';
$autowired = $connection->autowired ?? ($name === 'default');

// Skip if replacing storage is disabled
if (!$connection->storage) {
Expand All @@ -105,6 +107,9 @@ public function beforeCompileStorage(): void

$builder->addDefinition($this->prefix('connection.' . $name . '.journal'))
->setFactory(RedisJournal::class)
->setArguments([
'client' => $builder->getDefinition($this->prefix('connection.' . $name . '.client')),
])
->setAutowired(false);

$builder->addDefinition($this->prefix('connection.' . $name . '.storage'))
Expand All @@ -114,7 +119,7 @@ public function beforeCompileStorage(): void
'journal' => $builder->getDefinition($this->prefix('connection.' . $name . '.journal')),
'serializer' => $config->serializer,
])
->setAutowired($autowired);
->setAutowired($connection->storageAutowired ?? $autowired);

$storages++;
}
Expand Down