Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EntityManager decorator #22

Merged
merged 8 commits into from Nov 2, 2018
Copy path View file
@@ -4,12 +4,12 @@
use Doctrine\DBAL\Connection;
use Doctrine\ORM\Configuration;
use Doctrine\ORM\EntityManager as DoctrineEntityManager;
use Doctrine\ORM\Mapping\UnderscoreNamingStrategy;
use Nette\DI\CompilerExtension;
use Nette\DI\Helpers;
use Nette\DI\Statement;
use Nettrine\ORM\EntityManager;
use Nettrine\ORM\EntityManagerFactory;
use Nettrine\ORM\Exception\Logical\InvalidStateException;
use Nettrine\ORM\ManagerRegistry;
use Nettrine\ORM\Mapping\ContainerEntityListenerResolver;
@@ -120,14 +120,18 @@ public function loadEntityManagerConfiguration(): void
throw new InvalidStateException(sprintf('EntityManager class "%s" not found', $entityManagerClass));
}
// Entity Manager
$builder->addDefinition($this->prefix('entityManager'))
->setType($entityManagerClass)
->setFactory(EntityManagerFactory::class . '::create', [
// Original Entity Manager
$original = $builder->addDefinition($this->prefix('originalEntityManager'))
->setType(DoctrineEntityManager::class)
->setFactory(DoctrineEntityManager::class . '::create', [
$builder->getDefinitionByType(Connection::class), // Nettrine/DBAL
$this->prefix('@configuration'),
$entityManagerClass,
]);
])
->setAutowired(false);
// Entity Manager
$builder->addDefinition($this->prefix('entityManager'))
->setFactory($entityManagerClass, [$original]);

This comment has been minimized.

Copy link
@f3l1x

f3l1x Jun 15, 2018

Member

Is it still needed? Could we drop it?

This comment has been minimized.

Copy link
@MartkCz

MartkCz Jun 15, 2018

Author Member

It's EntityManagerDecorator registration

// ManagerRegistry
$builder->addDefinition($this->prefix('managerRegistry'))
Copy path View file
@@ -2,17 +2,9 @@
namespace Nettrine\ORM;
use Doctrine\Common\EventManager;
use Doctrine\DBAL\Connection;
use Doctrine\ORM\Configuration;
use Doctrine\ORM\EntityManager as DoctrineEntityManager;
use Doctrine\ORM\Decorator\EntityManagerDecorator;
class EntityManager extends DoctrineEntityManager
class EntityManager extends EntityManagerDecorator implements IEntityManager

This comment has been minimized.

Copy link
@f3l1x

f3l1x Jun 15, 2018

Member

Could we rename it to EntityManagerDecorator and drop implements?

{
public function __construct(Connection $connection, Configuration $configuration, EventManager $eventManager)
{
parent::__construct($connection, $configuration, $eventManager);
}
}
Copy path View file

This file was deleted.

Oops, something went wrong.
Copy path View file
@@ -0,0 +1,10 @@
<?php declare(strict_types = 1);
namespace Nettrine\ORM;
use Doctrine\ORM\EntityManagerInterface;
interface IEntityManager extends EntityManagerInterface
{
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.