1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2026-02-05 10:14:04 +00:00

Add tenant key resolver to define filesystem path suffix

This commit is contained in:
Leandro Guindani Gehlen 2024-06-28 15:29:18 -03:00
parent db9480f54e
commit 88ebe97991

View file

@ -17,6 +17,9 @@ class FilesystemTenancyBootstrapper implements TenancyBootstrapper
/** @var array */
public $originalPaths = [];
/** @var callable */
protected static $tenantKeyResolver;
public function __construct(Application $app)
{
$this->app = $app;
@ -33,9 +36,16 @@ class FilesystemTenancyBootstrapper implements TenancyBootstrapper
});
}
public static function resolveTenantKeyUsing(callable $tenantKeyResolver): void
{
static::$tenantKeyResolver = $tenantKeyResolver;
}
public function bootstrap(Tenant $tenant)
{
$suffix = $this->app['config']['tenancy.filesystem.suffix_base'] . $tenant->getTenantKey();
$tenantKey = static::$tenantKeyResolver ? (static::$tenantKeyResolver)($tenant) : $tenant->getTenantKey();
$suffix = $this->app['config']['tenancy.filesystem.suffix_base'] . $tenantKey;
// storage_path()
if ($this->app['config']['tenancy.filesystem.suffix_storage_path'] ?? true) {