1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2025-12-14 06:54:04 +00:00

general refactor, move more classes under Database namespace

This commit is contained in:
Samuel Štancl 2022-08-27 03:17:16 +02:00
parent 2d7e9dfd89
commit 40bf28c7d0
41 changed files with 122 additions and 133 deletions

View file

@ -7,14 +7,8 @@ namespace Stancl\Tenancy\Database;
use Illuminate\Config\Repository;
use Illuminate\Contracts\Foundation\Application;
use Illuminate\Database\DatabaseManager as BaseDatabaseManager;
use Stancl\Tenancy\Contracts\ManagesDatabaseUsers;
use Stancl\Tenancy\Contracts\TenantCannotBeCreatedException;
use Stancl\Tenancy\Contracts\TenantWithDatabase;
use Stancl\Tenancy\Exceptions\DatabaseManagerNotRegisteredException;
use Stancl\Tenancy\Exceptions\TenantDatabaseAlreadyExistsException;
use Stancl\Tenancy\Exceptions\TenantDatabaseUserAlreadyExistsException;
// todo move to Database namespace
use Stancl\Tenancy\Database\Contracts\TenantWithDatabase;
/**
* @internal Class is subject to breaking changes in minor and patch versions.
@ -97,11 +91,11 @@ class DatabaseManager
$manager = $tenant->database()->manager();
if ($manager->databaseExists($database = $tenant->database()->getName())) {
throw new TenantDatabaseAlreadyExistsException($database);
throw new Exceptions\TenantDatabaseAlreadyExistsException($database);
}
if ($manager instanceof ManagesDatabaseUsers && $manager->userExists($username = $tenant->database()->getUsername())) {
throw new TenantDatabaseUserAlreadyExistsException($username);
if ($manager instanceof Contracts\ManagesDatabaseUsers && $manager->userExists($username = $tenant->database()->getUsername())) {
throw new Exceptions\TenantDatabaseUserAlreadyExistsException($username);
}
}
}