mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 21:54:03 +00:00
Reorder Service Provider methods in execution sequence (#139)
This commit is contained in:
parent
0081726bda
commit
d00cf97e0e
1 changed files with 41 additions and 41 deletions
|
|
@ -11,12 +11,52 @@ use Stancl\Tenancy\TenancyBootstrappers\FilesystemTenancyBootstrapper;
|
|||
|
||||
class TenancyServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Register services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register(): void
|
||||
{
|
||||
$this->mergeConfigFrom(__DIR__ . '/../assets/config.php', 'tenancy');
|
||||
|
||||
$this->app->bind(Contracts\StorageDriver::class, function ($app) {
|
||||
return $app->make($app['config']['tenancy.storage_driver']);
|
||||
});
|
||||
$this->app->bind(Contracts\UniqueIdentifierGenerator::class, $this->app['config']['tenancy.unique_id_generator']);
|
||||
$this->app->singleton(DatabaseManager::class);
|
||||
$this->app->singleton(TenantManager::class);
|
||||
$this->app->bind(Tenant::class, function ($app) {
|
||||
return $app[TenantManager::class]->getTenant();
|
||||
});
|
||||
|
||||
foreach ($this->app['config']['tenancy.bootstrappers'] as $bootstrapper) {
|
||||
$this->app->singleton($bootstrapper);
|
||||
}
|
||||
|
||||
$this->app->singleton(Commands\Migrate::class, function ($app) {
|
||||
return new Commands\Migrate($app['migrator'], $app[DatabaseManager::class]);
|
||||
});
|
||||
$this->app->singleton(Commands\Rollback::class, function ($app) {
|
||||
return new Commands\Rollback($app['migrator'], $app[DatabaseManager::class]);
|
||||
});
|
||||
$this->app->singleton(Commands\Seed::class, function ($app) {
|
||||
return new Commands\Seed($app['db'], $app[DatabaseManager::class]);
|
||||
});
|
||||
|
||||
$this->app->bind('globalCache', function ($app) {
|
||||
return new CacheManager($app);
|
||||
});
|
||||
|
||||
$this->app->register(TenantRouteServiceProvider::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Bootstrap services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
public function boot(): void
|
||||
{
|
||||
$this->commands([
|
||||
Commands\Run::class,
|
||||
|
|
@ -55,44 +95,4 @@ class TenancyServiceProvider extends ServiceProvider
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Register services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
$this->mergeConfigFrom(__DIR__ . '/../assets/config.php', 'tenancy');
|
||||
|
||||
$this->app->bind(Contracts\StorageDriver::class, function ($app) {
|
||||
return $app->make($app['config']['tenancy.storage_driver']);
|
||||
});
|
||||
$this->app->bind(Contracts\UniqueIdentifierGenerator::class, $this->app['config']['tenancy.unique_id_generator']);
|
||||
$this->app->singleton(DatabaseManager::class);
|
||||
$this->app->singleton(TenantManager::class);
|
||||
$this->app->bind(Tenant::class, function ($app) {
|
||||
return $app[TenantManager::class]->getTenant();
|
||||
});
|
||||
|
||||
foreach ($this->app['config']['tenancy.bootstrappers'] as $bootstrapper) {
|
||||
$this->app->singleton($bootstrapper);
|
||||
}
|
||||
|
||||
$this->app->singleton(Commands\Migrate::class, function ($app) {
|
||||
return new Commands\Migrate($app['migrator'], $app[DatabaseManager::class]);
|
||||
});
|
||||
$this->app->singleton(Commands\Rollback::class, function ($app) {
|
||||
return new Commands\Rollback($app['migrator'], $app[DatabaseManager::class]);
|
||||
});
|
||||
$this->app->singleton(Commands\Seed::class, function ($app) {
|
||||
return new Commands\Seed($app['db'], $app[DatabaseManager::class]);
|
||||
});
|
||||
|
||||
$this->app->bind('globalCache', function ($app) {
|
||||
return new CacheManager($app);
|
||||
});
|
||||
|
||||
$this->app->register(TenantRouteServiceProvider::class);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue