mirror of
https://github.com/archtechx/tenancy.git
synced 2026-09-20 14:34:03 +00:00
minor polish
This commit is contained in:
parent
394a9fa562
commit
efc0877f10
4 changed files with 9 additions and 7 deletions
|
|
@ -339,7 +339,7 @@ class FilesystemTenancyBootstrapper implements TenancyBootstrapper
|
||||||
* Note that the returned path doesn't depend on suffix_storage_path.
|
* Note that the returned path doesn't depend on suffix_storage_path.
|
||||||
* That config option only affects the storage_path() helper.
|
* 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);
|
$bootstrapper = app(static::class);
|
||||||
|
|
||||||
|
|
@ -349,7 +349,7 @@ class FilesystemTenancyBootstrapper implements TenancyBootstrapper
|
||||||
/**
|
/**
|
||||||
* Name of the disk whose root the passed disk uses.
|
* 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.
|
* 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
|
* 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') {
|
while (config("filesystems.disks.$disk.driver") === 'scoped') {
|
||||||
if (in_array($disk, $visited, true)) {
|
if (in_array($disk, $visited, true)) {
|
||||||
|
// The disk and its parents reference each other, invalid
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$visited[] = $disk;
|
$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
|
// Laravel allows configuring the parent disk inline as an array, and such a disk has no name
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -151,12 +151,12 @@ class LogChannelBootstrapper implements TenancyBootstrapper
|
||||||
// The tenant log will be located at e.g. "storage/tenant{$tenantKey}/logs/laravel.log".
|
// The tenant log will be located at e.g. "storage/tenant{$tenantKey}/logs/laravel.log".
|
||||||
$originalChannelPath = $this->config->get("logging.channels.{$channel}.path");
|
$originalChannelPath = $this->config->get("logging.channels.{$channel}.path");
|
||||||
$centralStoragePath = FilesystemTenancyBootstrapper::getBoundCentralStoragePath();
|
$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.
|
// 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),
|
// 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).
|
// 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, '/\\')));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -121,7 +121,7 @@ class TenantAssetController implements HasMiddleware
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($tenant = tenant()) {
|
if ($tenant = tenant()) {
|
||||||
return FilesystemTenancyBootstrapper::getBoundTenantStoragePath($tenant) . '/app/public';
|
return FilesystemTenancyBootstrapper::getTenantStoragePath($tenant) . '/app/public';
|
||||||
}
|
}
|
||||||
|
|
||||||
return storage_path('app/public');
|
return storage_path('app/public');
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ class DeleteTenantStorage implements ShouldQueue
|
||||||
|
|
||||||
public function handle(): void
|
public function handle(): void
|
||||||
{
|
{
|
||||||
$tenantStoragePath = FilesystemTenancyBootstrapper::getBoundTenantStoragePath($this->tenant);
|
$tenantStoragePath = FilesystemTenancyBootstrapper::getTenantStoragePath($this->tenant);
|
||||||
$centralStoragePath = FilesystemTenancyBootstrapper::getBoundCentralStoragePath();
|
$centralStoragePath = FilesystemTenancyBootstrapper::getBoundCentralStoragePath();
|
||||||
|
|
||||||
if (realpath($tenantStoragePath) === realpath($centralStoragePath)) {
|
if (realpath($tenantStoragePath) === realpath($centralStoragePath)) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue