This repository has been archived on 2026-07-19. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
espocrm-base/application/Espo/Core/EntityManager.php
T
Yuri Kuznetsov 1f82e1fa6e change viewDefs
2013-11-28 13:49:17 +02:00

49 lines
1.0 KiB
PHP

<?php
namespace Espo\Core;
use Doctrine\Common\EventManager;
class EntityManager extends \Doctrine\ORM\Decorator\EntityManagerDecorator
{
private $metadata;
public function setMetadata($metadata)
{
$this->metadata = $metadata;
}
public function getRepository($entityName)
{
$className = $this->metadata->getEntityPath($entityName);
return $this->wrapped->getRepository($className);
}
public function find($entityName, $id)
{
$className = $this->metadata->getEntityPath($entityName);
return $this->wrapped->find($className, $id);
}
/**
* @return \Doctrine\ORM\EntityManager
*/
public function getWrapped()
{
return $this->wrapped;
}
public function createEntity($entityName)
{
$className = $this->metadata->getEntityPath($entityName);
$entity = new $className();
return $entity;
}
public function getEntityName($entity)
{
$className = get_class($entity);
return ltrim($className, '\\');
}
}