Skip to content

Commit

Permalink
Nette 3
Browse files Browse the repository at this point in the history
  • Loading branch information
mabar authored and Milan Felix Šulc committed Jun 28, 2019
1 parent a85fd81 commit ad71ea2
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 12 deletions.
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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": {
Expand All @@ -54,7 +54,7 @@
},
"extra": {
"branch-alias": {
"dev-develop": "0.5.x-dev"
"dev-develop": "0.6.x-dev"
}
}
}
8 changes: 7 additions & 1 deletion src/DI/NextrasOrmEventsExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();

Expand All @@ -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)) {
Expand All @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit ad71ea2

Please sign in to comment.