From d284d9108f335ca2c9a9ee2ec16bebfbaabf0b35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Milan=20Felix=20=C5=A0ulc?= Date: Mon, 3 Jul 2023 18:12:16 +0200 Subject: [PATCH] Composer: use nette/di directly --- composer.json | 2 +- src/DI/AnnotationsExtension.php | 16 ++++------------ 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/composer.json b/composer.json index ee7307b..e078299 100644 --- a/composer.json +++ b/composer.json @@ -13,7 +13,7 @@ ], "require": { "php": ">=8.1", - "contributte/di": "^0.6.0", + "nette/di": "^3.1.2", "doctrine/annotations": "^1.6.1", "nettrine/cache": "^0.4.0 || ^0.5.0" }, diff --git a/src/DI/AnnotationsExtension.php b/src/DI/AnnotationsExtension.php index 285fab3..655731c 100644 --- a/src/DI/AnnotationsExtension.php +++ b/src/DI/AnnotationsExtension.php @@ -2,13 +2,12 @@ namespace Nettrine\Annotations\DI; -use Contributte\DI\Extension\CompilerExtension; use Doctrine\Common\Annotations\AnnotationReader; use Doctrine\Common\Annotations\AnnotationRegistry; use Doctrine\Common\Annotations\CachedReader; use Doctrine\Common\Annotations\Reader; use Doctrine\Common\Cache\Cache; -use Nette\DI\Definitions\Definition; +use Nette\DI\CompilerExtension; use Nette\DI\Definitions\Statement; use Nette\PhpGenerator\ClassType; use Nette\PhpGenerator\Literal; @@ -38,9 +37,6 @@ public function getConfigSchema(): Schema ]); } - /** - * Register services - */ public function loadConfiguration(): void { $builder = $this->getContainerBuilder(); @@ -56,13 +52,9 @@ public function loadConfiguration(): void } if ($config->cache !== null) { - $cacheName = $this->prefix('cache'); - $cacheDefinition = $this->getHelper()->getDefinitionFromConfig($config->cache, $cacheName); - - // If service is extension specific, then disable autowiring - if ($cacheDefinition instanceof Definition && $cacheDefinition->getName() === $cacheName) { - $cacheDefinition->setAutowired(false); - } + $cacheDefinition = $builder->addDefinition($this->prefix('cache')); + $cacheDefinition->setFactory($config->cache) + ->setAutowired(false); } else { $cacheDefinition = '@' . Cache::class; }