mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-13 17:04:03 +00:00
Interfaces -> Contracts
This commit is contained in:
parent
e4f27e7396
commit
89bf90f595
4 changed files with 81 additions and 0 deletions
29
src/Contracts/StorageDriver.php
Normal file
29
src/Contracts/StorageDriver.php
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Stancl\Tenancy\Contracts;
|
||||||
|
|
||||||
|
interface StorageDriver
|
||||||
|
{
|
||||||
|
public function identifyTenant(string $domain): array;
|
||||||
|
|
||||||
|
/** @return array[] */
|
||||||
|
public function getAllTenants(array $uuids = []): array;
|
||||||
|
|
||||||
|
public function getTenantById(string $uuid, array $fields = []): array;
|
||||||
|
|
||||||
|
public function getTenantIdByDomain(string $domain): ?string;
|
||||||
|
|
||||||
|
public function createTenant(string $domain, string $uuid): array;
|
||||||
|
|
||||||
|
public function deleteTenant(string $uuid): bool;
|
||||||
|
|
||||||
|
public function get(string $uuid, string $key);
|
||||||
|
|
||||||
|
public function getMany(string $uuid, array $keys): array;
|
||||||
|
|
||||||
|
public function put(string $uuid, string $key, $value);
|
||||||
|
|
||||||
|
public function putMany(string $uuid, array $values): array;
|
||||||
|
}
|
||||||
11
src/Contracts/TenancyBootstrapper.php
Normal file
11
src/Contracts/TenancyBootstrapper.php
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Stancl\Tenancy\Contracts;
|
||||||
|
|
||||||
|
use Stancl\Tenancy\Tenant;
|
||||||
|
|
||||||
|
interface TenancyBootstrapper
|
||||||
|
{
|
||||||
|
public function start(Tenant $tenant); // todo better name?
|
||||||
|
public function end(Tenant $tenant); // todo arg?
|
||||||
|
}
|
||||||
24
src/Contracts/TenantDatabaseManager.php
Normal file
24
src/Contracts/TenantDatabaseManager.php
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Stancl\Tenancy\Contracts;
|
||||||
|
|
||||||
|
interface TenantDatabaseManager
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Create a database.
|
||||||
|
*
|
||||||
|
* @param string $name Name of the database.
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function createDatabase(string $name): bool;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete a database.
|
||||||
|
*
|
||||||
|
* @param string $name Name of the database.
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function deleteDatabase(string $name): bool;
|
||||||
|
}
|
||||||
17
src/Contracts/UniqueIdentifierGenerator.php
Normal file
17
src/Contracts/UniqueIdentifierGenerator.php
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Stancl\Tenancy\Contracts;
|
||||||
|
|
||||||
|
interface UniqueIdentifierGenerator
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Generate a unique identifier.
|
||||||
|
*
|
||||||
|
* @param string $domain
|
||||||
|
* @param array $data
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function handle(string $domain, array $data = []): string;
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue