/** * Create a new EntityManager * * @param Storage $storageDriver * @param Configuration $config */ public function __construct(Storage $storageDriver, Configuration $config) { $cmf = new ClassMetadataFactory($config->getMappingDriverImpl()); $cmf->setCacheDriver($config->getMetadataCache()); $this->unitOfWork = new UnitOfWork($cmf, $storageDriver, $config); $this->storageDriver = $storageDriver; }
public function __construct(ClassMetadataFactory $cmf, Storage $storageDriver, Configuration $config = null) { $this->cmf = $cmf; $this->storageDriver = $storageDriver; $this->idConverter = $config->getIdConverterStrategy(); $this->idHandler = $storageDriver->supportsCompositePrimaryKeys() ? new Id\CompositeIdHandler() : new Id\SingleIdHandler(); }
public function createManager($storage = null) { $cache = new ArrayCache(); $storage = $storage ?: new DoctrineCacheStorage($cache); $reader = new \Doctrine\Common\Annotations\AnnotationReader(); $metadata = new AnnotationDriver($reader); $config = new Configuration(); $config->setMappingDriverImpl($metadata); $config->setMetadataCache($cache); return new EntityManager($storage, $config); }
public function createManager($storage = null, $driver = 'annotation') { $cache = new ArrayCache(); $storage = $storage ?: new DoctrineCacheStorage($cache); switch ($driver) { case 'annotation': $reader = new \Doctrine\Common\Annotations\AnnotationReader(); $metadata = new Mapping\AnnotationDriver($reader); break; case 'yaml': $metadata = new Mapping\YamlDriver(__DIR__ . '/fixtures/yaml'); break; case 'xml': $metadata = new Mapping\XmlDriver(__DIR__ . '/fixtures/xml'); break; } $config = new Configuration(); $config->setMappingDriverImpl($metadata); $config->setMetadataCache($cache); return new EntityManager($storage, $config); }
public function testDefaultIdConverterStrategy() { $config = new Configuration(); $strategy = $config->getIdConverterStrategy(); $this->assertInstanceOf('Doctrine\\KeyValueStore\\Id\\NullIdConverter', $strategy); }