Skip to content

managlea/ResourceMapper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ResourceMapper

ResourceMapper maps resources with correct entity class and entity manager

Build Status Scrutinizer Code Quality Code Coverage
Code Climate Test Coverage
SensioLabsInsight
Codacy Badge
Build Status Circle CI
PHP Versions tested

Basic usage

Configuration file

# resource_mapping.yml

default_entity_manager: Managlea\Component\DoctrineEntityManager
mapping:
  foo:
    object_name: Entities\Foo
  bar:
    entity_manager: BarEntityManager
    object_name: Entities\Bar

Code execution

// 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);

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages