mirror of
https://github.com/archtechx/tenancy.git
synced 2026-09-20 16:44:04 +00:00
Make storage symlinks point to the tenant's disk root instead of storage_path()
possibleTenantSymlinks() resolved the root_override template on its own, using storage_path() for %storage_path% and leaving %original_storage_path% and %tenant% unreplaced. Let the FS bootstrapper resolve the placeholders tenant instead, so the symlinks point where the disks actually write.
This commit is contained in:
parent
179114bfb7
commit
98d86478e7
1 changed files with 11 additions and 6 deletions
|
|
@ -7,15 +7,21 @@ namespace Stancl\Tenancy\Concerns;
|
|||
use Exception;
|
||||
use Stancl\Tenancy\Contracts\Tenant;
|
||||
|
||||
/**
|
||||
* Requires FilesystemTenancyBootstrapper to be enabled, since the tenant symlinks
|
||||
* point to the disk roots scoped by the bootstrapper.
|
||||
*
|
||||
* @see \Stancl\Tenancy\Bootstrappers\FilesystemTenancyBootstrapper
|
||||
*/
|
||||
trait DealsWithTenantSymlinks
|
||||
{
|
||||
/**
|
||||
* Get all possible tenant symlinks, existing or not (array of ['public path' => 'storage path']).
|
||||
* Get all possible tenant symlinks, existing or not (array of ['public path' => 'disk root']).
|
||||
*
|
||||
* Tenants can have a symlink for each disk registered in the tenancy.filesystem.url_override config.
|
||||
* This is used for creating all possible tenant symlinks and removing all existing tenant symlinks.
|
||||
* The same storage path can be symlinked to multiple public paths, which is why the public path
|
||||
* is the Collection key.
|
||||
* The same disk root can be symlinked to multiple public paths, which is why the public path
|
||||
* is the array key.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
|
|
@ -26,7 +32,7 @@ trait DealsWithTenantSymlinks
|
|||
$rootOverrides = config('tenancy.filesystem.root_override');
|
||||
|
||||
$tenantKey = $tenant->getTenantKey();
|
||||
$tenantStoragePath = tenancy()->run($tenant, fn () => storage_path());
|
||||
$tenantDisks = tenancy()->run($tenant, fn () => config('filesystems.disks'));
|
||||
|
||||
/** @var array<string, string> $symlinks */
|
||||
$symlinks = [];
|
||||
|
|
@ -45,9 +51,8 @@ trait DealsWithTenantSymlinks
|
|||
}
|
||||
|
||||
$publicPath = str_replace('%tenant%', (string) $tenantKey, $publicPath);
|
||||
$storagePath = str_replace('%storage_path%', $tenantStoragePath, $rootOverrides[$disk]);
|
||||
|
||||
$symlinks[public_path($publicPath)] = $storagePath;
|
||||
$symlinks[public_path($publicPath)] = $tenantDisks[$disk]['root'];
|
||||
}
|
||||
|
||||
return $symlinks;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue