mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-04 12:34:03 +00:00
Refactor disk management in FilesystemTenancyBootstrapper
Refactor disk management by introducing forgetDisks method to handle tenant and scoped disks more efficiently.
This commit is contained in:
parent
e1b007946b
commit
ed538ccf92
1 changed files with 19 additions and 2 deletions
|
|
@ -53,7 +53,7 @@ class FilesystemTenancyBootstrapper implements TenancyBootstrapper
|
||||||
}
|
}
|
||||||
|
|
||||||
// Storage facade
|
// Storage facade
|
||||||
Storage::forgetDisk($this->app['config']['tenancy.filesystem.disks']);
|
$this->forgetDisks();
|
||||||
|
|
||||||
foreach ($this->app['config']['tenancy.filesystem.disks'] as $disk) {
|
foreach ($this->app['config']['tenancy.filesystem.disks'] as $disk) {
|
||||||
$originalRoot = $this->app['config']["filesystems.disks.{$disk}.root"];
|
$originalRoot = $this->app['config']["filesystems.disks.{$disk}.root"];
|
||||||
|
|
@ -85,9 +85,26 @@ class FilesystemTenancyBootstrapper implements TenancyBootstrapper
|
||||||
$this->app['url']->setAssetRoot($this->app['config']['app.asset_url']);
|
$this->app['url']->setAssetRoot($this->app['config']['app.asset_url']);
|
||||||
|
|
||||||
// Storage facade
|
// Storage facade
|
||||||
Storage::forgetDisk($this->app['config']['tenancy.filesystem.disks']);
|
$this->forgetDisks();
|
||||||
foreach ($this->app['config']['tenancy.filesystem.disks'] as $disk) {
|
foreach ($this->app['config']['tenancy.filesystem.disks'] as $disk) {
|
||||||
$this->app['config']["filesystems.disks.{$disk}.root"] = $this->originalPaths['disks'][$disk];
|
$this->app['config']["filesystems.disks.{$disk}.root"] = $this->originalPaths['disks'][$disk];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function forgetDisks(): void
|
||||||
|
{
|
||||||
|
$tenantDisks = $this->app['config']['tenancy.filesystem.disks'];
|
||||||
|
$scopedDisks = [];
|
||||||
|
|
||||||
|
foreach ($this->app['config']['filesystems.disks'] as $name => $disk) {
|
||||||
|
if (isset($disk['driver'], $disk['disk'])
|
||||||
|
&& $disk['driver'] === 'scoped'
|
||||||
|
&& in_array($disk['disk'], $tenantDisks, true)
|
||||||
|
&& ! in_array($name, $scopedDisks, true)) {
|
||||||
|
$scopedDisks[] = $name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Storage::forgetDisk([...$tenantDisks, ...$scopedDisks]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue