ResourceMapper maps resources with correct entity class and entity manager
# resource_mapping.yml
default_entity_manager: Managlea\Component\DoctrineEntityManager
mapping:
foo:
object_name: Entities\Foo
bar:
entity_manager: BarEntityManager
object_name: Entities\Bar
// Create new ResourceMapper
$resourceMapper = new ResourceMapper;
// Get entityManagerName (string) for resource
$entityManagerName = $resourceMapper->getEntityManagerName('foo');
// Create new EntityManager (instanceof Managlea\Component\EntityManagerInterface) by name
$entityManager = new EntityManagerFactory::create($entityManagerName);
// Get objectName (string) for resource
$objectName = $resourceMapper->getObjectName('foo');
// Use objectName in entity manager to retrieve entity (object)
$entity = $entityManager->get($objectName, 1);