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

Add symlink support for prefixed disks

Disk prefixes are no longer ignored by tenants:link. possibleTenantSymlinks() now appends them to both the public path and the disk root.

CreateStorageSymlinksAction now creates parent directories for the symlinks in the public/ directory (e.g. for a disk with 'abc/def' prefix, the 'abc/def' subdirectory will be created inside public/<url_override>).

RemoveStorageSymlinksAction removes the directories that  CreateStorageSymlinksAction creates for the symlinks.
This commit is contained in:
lukinovec 2026-09-09 12:18:04 +02:00
parent 9673464128
commit b2b8d50edb
4 changed files with 144 additions and 2 deletions

View file

@ -32,12 +32,24 @@ class RemoveStorageSymlinksAction
protected function removeLink(string $publicPath, Tenant $tenant): void
{
$files = app()->make('files');
if ($this->symlinkExists($publicPath)) {
event(new RemovingStorageSymlink($tenant));
app()->make('files')->delete($publicPath);
$files->delete($publicPath);
event(new StorageSymlinkRemoved($tenant));
}
// Remove the directories CreateStorageSymlinksAction created for the symlink
// until a non-empty one is reached.
$directory = dirname($publicPath);
while ($directory !== public_path() && $files->isEmptyDirectory($directory)) {
$files->deleteDirectory($directory);
$directory = dirname($directory);
}
}
}