From d0834d2a766459c8e3741e9e77adda2aa5df6ade Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Milan=20Felix=20=C5=A0ulc?= Date: Mon, 3 Jul 2023 18:14:24 +0200 Subject: [PATCH] Composer: use nette/di directly --- composer.json | 2 +- src/DI/CacheExtension.php | 10 +++------- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/composer.json b/composer.json index 4aeb3da..d0fa923 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,7 @@ ], "require": { "php": ">=8.1", - "contributte/di": "^0.6.0", + "nette/di": "^3.1.2", "doctrine/cache": "^1.13.0" }, "require-dev": { diff --git a/src/DI/CacheExtension.php b/src/DI/CacheExtension.php index 1779e89..fff2d5c 100644 --- a/src/DI/CacheExtension.php +++ b/src/DI/CacheExtension.php @@ -2,7 +2,6 @@ namespace Nettrine\Cache\DI; -use Contributte\DI\Helper\ExtensionDefinitionsHelper; use Doctrine\Common\Cache\ApcuCache; use Doctrine\Common\Cache\Cache; use Doctrine\Common\Cache\PhpFileCache; @@ -35,11 +34,9 @@ public function loadConfiguration(): void $builder = $this->getContainerBuilder(); $config = $this->config; - $driverName = $this->prefix('driver'); - if ($config->driver === null) { // auto choose - $driverDefinition = $builder->addDefinition($driverName) + $driverDefinition = $builder->addDefinition($this->prefix('driver')) ->setType(Cache::class); if (isset($builder->parameters['tempDir'])) { @@ -55,9 +52,8 @@ public function loadConfiguration(): void )); } } else { - // load from config - $definitionsHelper = new ExtensionDefinitionsHelper($this->compiler); - $definitionsHelper->getDefinitionFromConfig($config->driver, $driverName); + $builder->addDefinition($this->prefix('driver')) + ->setFactory($config->driver); } }