diff --git a/src/DI/RedisExtension.php b/src/DI/RedisExtension.php index f24c04d..5463558 100644 --- a/src/DI/RedisExtension.php +++ b/src/DI/RedisExtension.php @@ -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( @@ -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) @@ -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) { @@ -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')) @@ -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++; }