From ad71ea203e45cca249f97790bf20b468990bc0e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Barto=C5=A1?= Date: Fri, 28 Jun 2019 16:16:29 +0200 Subject: [PATCH] Nette 3 --- README.md | 13 +++++++------ composer.json | 10 +++++----- src/DI/NextrasOrmEventsExtension.php | 8 +++++++- 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index fe2e588..e8df751 100644 --- a/README.md +++ b/README.md @@ -24,12 +24,13 @@ Doctrine-like events for Nextras ORM entity lifecycle. ## Versions -| State | Version | Branch | PHP | | -|-------------|---------|----------|----------|-| -| development | `^0.5` | `master` | `>= 7.1` || -| stable | `^0.4` | `master` | `>= 7.1` || -| stable | `^0.3` | `master` | `>= 5.6` || -| stable | `^0.2` | `master` | `>= 5.6` |(old namespace)| +| State | Version | Branch | Nette | PHP | | +|-------------|---------|----------|-------|---------|-| +| dev | `^0.6` | `master` | 3.0+ | `^7.2` | | +| stable | `^0.5` | `master` | 3.0+ | `^7.2` | | +| stable | `^0.4` | `master` | 2.4 | `>=7.1` | | +| stable | `^0.3` | `master` | 2.4 | `>=5.6` | | +| stable | `^0.2` | `master` | 2.4 | `>=5.6` | (old namespace) ## Maintainers diff --git a/composer.json b/composer.json index 7d4efb9..d242000 100644 --- a/composer.json +++ b/composer.json @@ -19,13 +19,13 @@ ], "require": { "php": "^7.2", - "nette/di": "~2.4.10", + "nette/di": "~3.0.0", "nette/reflection": "~2.4.2", - "nextras/orm": "^3.0.1" + "nextras/orm": "^3.1.0" }, "require-dev": { "mockery/mockery": "^0.9.9", - "nette/caching": "~2.5.6", + "nette/caching": "~3.0.0", "ninjify/qa": "^0.8.0", "ninjify/nunjuck": "^0.2.0", "phpstan/extension-installer": "^1.0", @@ -35,7 +35,7 @@ "phpstan/phpstan-strict-rules": "^0.11" }, "conflict": { - "nette/utils": "<2.5.2" + "nette/di": "<=3.0.0-RC" }, "autoload": { "psr-4": { @@ -54,7 +54,7 @@ }, "extra": { "branch-alias": { - "dev-develop": "0.5.x-dev" + "dev-develop": "0.6.x-dev" } } } diff --git a/src/DI/NextrasOrmEventsExtension.php b/src/DI/NextrasOrmEventsExtension.php index 50cd4f9..4016906 100644 --- a/src/DI/NextrasOrmEventsExtension.php +++ b/src/DI/NextrasOrmEventsExtension.php @@ -11,6 +11,7 @@ use Contributte\Nextras\Orm\Events\Listeners\BeforeRemoveListener; use Contributte\Nextras\Orm\Events\Listeners\BeforeUpdateListener; use Nette\DI\CompilerExtension; +use Nette\DI\Definitions\ServiceDefinition; use Nette\DI\ServiceCreationException; use Nette\Reflection\ClassType; use Nette\Reflection\IAnnotation; @@ -82,6 +83,8 @@ private function loadEntityMapping(): array $repositories = $builder->findByType(IRepository::class); foreach ($repositories as $repository) { + assert($repository instanceof ServiceDefinition); + /** @var string $repositoryClass */ $repositoryClass = $repository->getEntity(); @@ -107,6 +110,8 @@ private function loadEntityMapping(): array */ private function loadListeners(array $mapping): void { + $builder = $this->getContainerBuilder(); + foreach ($mapping as $entity => $repository) { // Test invalid class name if (!class_exists($entity)) { @@ -117,7 +122,7 @@ private function loadListeners(array $mapping): void $rf = new ClassType($entity); // Add entity as dependency - $this->getContainerBuilder()->addDependency($rf->getFileName()); + $builder->addDependency($rf); // Try all annotations foreach (self::$annotations as $annotation => $events) { @@ -149,6 +154,7 @@ private function loadListenerByAnnotation(array $events, string $repository, str // Get definitions $repositoryDef = $builder->getDefinition($rsn); + assert($repositoryDef instanceof ServiceDefinition); $listenerDef = $builder->getDefinition($lsn); foreach ($events as $event => $interface) {