mirror of
https://github.com/espocrm/espocrm.git
synced 2026-07-01 08:26:04 +00:00
27 lines
486 B
PHP
27 lines
486 B
PHP
<?php
|
|
|
|
namespace Espo\ORM;
|
|
|
|
class EntityFactory
|
|
{
|
|
protected $metadata;
|
|
|
|
protected $entityManager;
|
|
|
|
public function __construct(EntityManager $entityManager, Metadata $metadata)
|
|
{
|
|
$this->entityManager = $entityManager;
|
|
$this->metadata = $metadata;
|
|
}
|
|
public function create($name)
|
|
{
|
|
$className = $this->entityManager->normalizeEntityName($name);
|
|
$defs = $this->metadata->get($name);
|
|
$entity = new $className($defs, $this->entityManager);
|
|
return $entity;
|
|
}
|
|
|
|
}
|
|
|
|
|