Doctrine\ORM\EntityManager::__construct PHP Method

__construct() protected method

Creates a new EntityManager that operates on the given database connection and uses the given Configuration and EventManager implementations.
protected __construct ( Doctrine\DBAL\Connection $conn, Doctrine\ORM\Configuration $config, Doctrine\Common\EventManager $eventManager )
$conn Doctrine\DBAL\Connection
$config Doctrine\ORM\Configuration
$eventManager Doctrine\Common\EventManager
    protected function __construct(Connection $conn, Configuration $config, EventManager $eventManager)
    {
        $this->conn = $conn;
        $this->config = $config;
        $this->eventManager = $eventManager;

        $metadataFactoryClassName = $config->getClassMetadataFactoryName();
        $this->metadataFactory = new $metadataFactoryClassName;
        $this->metadataFactory->setEntityManager($this);
        $this->metadataFactory->setCacheDriver($this->config->getMetadataCacheImpl());
        
        $this->unitOfWork = new UnitOfWork($this);
        $this->proxyFactory = new ProxyFactory($this,
                $config->getProxyDir(),
                $config->getProxyNamespace(),
                $config->getAutoGenerateProxyClasses());
    }

Usage Example

コード例 #1
0
 protected function __construct(Doctrine\DBAL\Connection $conn, Doctrine\ORM\Configuration $config, Doctrine\Common\EventManager $eventManager)
 {
     parent::__construct($conn, $config, $eventManager);
     if ($conn instanceof Kdyby\Doctrine\Connection) {
         $conn->bindEntityManager($this);
     }
 }
All Usage Examples Of Doctrine\ORM\EntityManager::__construct