1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2026-09-20 11:14:03 +00:00

minor polish

This commit is contained in:
Samuel Stancl 2026-09-06 22:09:02 -07:00
parent 394a9fa562
commit efc0877f10
4 changed files with 9 additions and 7 deletions

View file

@ -339,7 +339,7 @@ class FilesystemTenancyBootstrapper implements TenancyBootstrapper
* Note that the returned path doesn't depend on suffix_storage_path.
* That config option only affects the storage_path() helper.
*/
public static function getBoundTenantStoragePath(Tenant $tenant): string
public static function getTenantStoragePath(Tenant $tenant): string
{
$bootstrapper = app(static::class);
@ -349,7 +349,7 @@ class FilesystemTenancyBootstrapper implements TenancyBootstrapper
/**
* Name of the disk whose root the passed disk uses.
*
* Disks using the 'scoped' driver have no root or url of their own -- they inherit these from their parent disk,
* Disks using the 'scoped' driver have no root or url of their own -- they inherit those from their parent disk,
* which can be scoped as well, so only the final/base parent has to be tenant-aware.
*
* Returns null if the chain doesn't end with a named disk, i.e. when a parent disk is
@ -362,12 +362,14 @@ class FilesystemTenancyBootstrapper implements TenancyBootstrapper
while (config("filesystems.disks.$disk.driver") === 'scoped') {
if (in_array($disk, $visited, true)) {
// The disk and its parents reference each other, invalid
return null;
}
$visited[] = $disk;
$disk = config("filesystems.disks.$disk.disk");
if (! is_string($disk = config("filesystems.disks.$disk.disk"))) {
if (! is_string($disk)) {
// Laravel allows configuring the parent disk inline as an array, and such a disk has no name
return null;
}

View file

@ -151,12 +151,12 @@ class LogChannelBootstrapper implements TenancyBootstrapper
// The tenant log will be located at e.g. "storage/tenant{$tenantKey}/logs/laravel.log".
$originalChannelPath = $this->config->get("logging.channels.{$channel}.path");
$centralStoragePath = FilesystemTenancyBootstrapper::getBoundCentralStoragePath();
$tenantStoragePath = FilesystemTenancyBootstrapper::getBoundTenantStoragePath($tenant);
$tenantStoragePath = FilesystemTenancyBootstrapper::getTenantStoragePath($tenant);
// The tenant log will inherit the segment that follows the storage path from the central channel path config.
// For example, if a channel's path is configured to storage_path('logs/foo.log') (storage/logs/foo.log),
// the '/logs/foo.log' segment will be placed within the tenant storage path (so the log will be located at storage/tenant123/logs/foo.log).
$this->config->set("logging.channels.{$channel}.path", $tenantStoragePath . Str::after($originalChannelPath, $centralStoragePath));
$this->config->set("logging.channels.{$channel}.path", $tenantStoragePath . Str::after($originalChannelPath, rtrim($centralStoragePath, '/\\')));
}
}
}

View file

@ -121,7 +121,7 @@ class TenantAssetController implements HasMiddleware
}
if ($tenant = tenant()) {
return FilesystemTenancyBootstrapper::getBoundTenantStoragePath($tenant) . '/app/public';
return FilesystemTenancyBootstrapper::getTenantStoragePath($tenant) . '/app/public';
}
return storage_path('app/public');

View file

@ -34,7 +34,7 @@ class DeleteTenantStorage implements ShouldQueue
public function handle(): void
{
$tenantStoragePath = FilesystemTenancyBootstrapper::getBoundTenantStoragePath($this->tenant);
$tenantStoragePath = FilesystemTenancyBootstrapper::getTenantStoragePath($this->tenant);
$centralStoragePath = FilesystemTenancyBootstrapper::getBoundCentralStoragePath();
if (realpath($tenantStoragePath) === realpath($centralStoragePath)) {