Skip to content

Commit

Permalink
Fix Laravel service provider
Browse files Browse the repository at this point in the history
  • Loading branch information
leomarquine committed Sep 11, 2018
1 parent 4a148e7 commit 186d25d
Showing 1 changed file with 4 additions and 35 deletions.
39 changes: 4 additions & 35 deletions src/EtlServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,49 +6,18 @@

class EtlServiceProvider extends ServiceProvider
{
/**
* List of the supported database connections.
*
* @var array
*/
protected $supportedConnections = [
'mysql', 'pgsql', 'sqlite',
];

/**
* Perform post-registration booting of services.
*
* @return void
*/
public function boot()
{
Etl::set('path', storage_path('app'));
$connections = $this->app['config']['database.connections'];
$connections['default'] = $connections[$this->app['config']['database.default']];

$this->addConnections();
}

/**
* Add the connections to the ETL configuration.
*
* @return void
*/
protected function addConnections()
{
foreach ($this->getSupportedConnections() as $name => $config) {
Etl::addConnection($config, $name == config('database.default') ? 'default' : $name);
foreach ($connections as $name => $config) {
Etl::service('db')->addConnection($config, $name);
}
}

/**
* Get the supported connections configuration.
*
* @return array
*/
protected function getSupportedConnections()
{
return array_intersect_key(
config('database.connections'),
array_flip($this->supportedConnections)
);
}
}

0 comments on commit 186d25d

Please sign in to comment.