Example #1
0
 public function test_can_replace_an_existing_driver()
 {
     $this->manager->extend('oci8', function () {
         return 'connection';
     });
     $this->assertEquals('connection', $this->manager->driver('oci8'));
 }
Example #2
0
 /**
  * @param array $settings
  *
  * @return EntityManagerInterface
  */
 public function create($settings = [])
 {
     $configuration = $this->meta->driver(array_get($settings, 'meta'), $settings);
     $connection = $this->connection->driver($this->getConnectionDriverName($settings));
     $this->setNamingStrategy($settings, $configuration);
     $this->setCustomFunctions($configuration);
     $this->setCacheSettings($configuration);
     $this->configureProxies($settings, $configuration);
     $this->setCustomMappingDriverChain($settings, $configuration);
     $this->registerPaths($settings, $configuration);
     $configuration->setDefaultRepositoryClassName(array_get($settings, 'repository', EntityRepository::class));
     $manager = EntityManager::create($connection, $configuration);
     $manager = $this->decorateManager($settings, $manager);
     $this->setLogger($manager, $configuration);
     $this->registerListeners($settings, $manager);
     $this->registerSubscribers($settings, $manager);
     $this->registerFilters($settings, $configuration, $manager);
     return $manager;
 }
Example #3
0
 /**
  * @param array $settings
  *
  * @return EntityManagerInterface
  */
 public function create(array $settings = [])
 {
     $configuration = $this->setup->createConfiguration(array_get($settings, 'dev', false), array_get($settings, 'proxies.path'), $this->cache->driver());
     $configuration->setMetadataDriverImpl($this->meta->driver(array_get($settings, 'meta'), $settings));
     $driver = $this->getConnectionDriver($settings);
     $connection = $this->connection->driver($driver['driver'], $driver);
     $this->setNamingStrategy($settings, $configuration);
     $this->setCustomFunctions($configuration);
     $this->setCustomHydrators($settings, $configuration);
     $this->setCacheSettings($configuration);
     $this->configureProxies($settings, $configuration);
     $this->setCustomMappingDriverChain($settings, $configuration);
     $this->registerPaths($settings, $configuration);
     $this->setRepositoryFactory($settings, $configuration);
     $configuration->setDefaultRepositoryClassName(array_get($settings, 'repository', EntityRepository::class));
     $manager = EntityManager::create($connection, $configuration);
     $manager = $this->decorateManager($settings, $manager);
     $this->setLogger($manager, $configuration);
     $this->registerListeners($settings, $manager);
     $this->registerSubscribers($settings, $manager);
     $this->registerFilters($settings, $configuration, $manager);
     return $manager;
 }
Example #4
0
 public function test_a_string_class_can_be_use_as_extend()
 {
     ConnectionManager::extend('custom3', StubConnection::class);
     $driver = ConnectionManager::resolve('custom3');
     $this->assertContains('stub', $driver);
 }
Example #5
0
 /**
  * Register the connections
  * @return array
  */
 protected function setupConnection()
 {
     ConnectionManager::registerConnections($this->app->config->get('database.connections', []));
 }