Created
August 9, 2019 15:25
-
-
Save raitocz/faec272acd3868c7a3d342645e0e408d to your computer and use it in GitHub Desktop.
Traits to get multiple entity managers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php declare(strict_types=1); | |
namespace EryseClient\Utility; | |
use App\Utility\EntityManager\LocalEntityManagerTrait; | |
use App\Utility\EntityManager\RemoteEntityManagerTrait; | |
trait EntityManagersTrait | |
{ | |
use LocalEntityManagerTrait; | |
use RemoteEntityManagerTrait; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php declare(strict_types=1); | |
namespace App\Utility\EntityManager; | |
use Doctrine\Common\Persistence\ManagerRegistry; | |
use Doctrine\ORM\EntityManagerInterface; | |
trait LocalEntityManagerTrait | |
{ | |
/** @var EntityManagerInterface $em */ | |
protected $emLocal; | |
/** | |
* @required | |
* @param ManagerRegistry $managerRegistry | |
*/ | |
public function setLocalEntityManager(ManagerRegistry $managerRegistry) | |
{ | |
$this->emLocal = $managerRegistry->getManager('app-local'); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php declare(strict_types=1); | |
namespace App\Utility\EntityManager; | |
use Doctrine\Common\Persistence\ManagerRegistry; | |
use Doctrine\ORM\EntityManagerInterface; | |
trait RemoteEntityManagerTrait | |
{ | |
/** @var EntityManagerInterface $em */ | |
protected $emRemote; | |
/** | |
* @required | |
* @param ManagerRegistry $managerRegistry | |
*/ | |
public function setRemoteEntityManager(ManagerRegistry $managerRegistry) | |
{ | |
$this->emRemote = $managerRegistry->getManager('app-remote'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment