1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2026-02-05 20:34:03 +00:00

Filesystem adapter updated

This commit is contained in:
George 2022-02-12 13:58:15 +01:00
parent cf7d6eebb6
commit 8445e3ebb8
2 changed files with 11 additions and 14 deletions

View file

@ -25,6 +25,7 @@ services:
stdin_open: true stdin_open: true
tty: true tty: true
mysql: mysql:
platform: linux/x86_64
image: mysql:5.7 image: mysql:5.7
environment: environment:
MYSQL_ROOT_PASSWORD: password MYSQL_ROOT_PASSWORD: password
@ -36,6 +37,7 @@ services:
timeout: 10s timeout: 10s
retries: 10 retries: 10
mysql2: mysql2:
platform: linux/x86_64
image: mysql:5.7 image: mysql:5.7
environment: environment:
MYSQL_ROOT_PASSWORD: password MYSQL_ROOT_PASSWORD: password
@ -47,6 +49,7 @@ services:
timeout: 10s timeout: 10s
retries: 10 retries: 10
postgres: postgres:
platform: linux/x86_64
image: postgres:11 image: postgres:11
environment: environment:
POSTGRES_PASSWORD: password POSTGRES_PASSWORD: password

View file

@ -54,23 +54,20 @@ class FilesystemTenancyBootstrapper implements TenancyBootstrapper
} }
// Storage facade // Storage facade
Storage::forgetDisk($this->app['config']['tenancy.filesystem.disks']);
foreach ($this->app['config']['tenancy.filesystem.disks'] as $disk) { foreach ($this->app['config']['tenancy.filesystem.disks'] as $disk) {
/** @var FilesystemAdapter $filesystemDisk */ $root = $this->app['config']["filesystems.disks.{$disk}.root"];
$filesystemDisk = Storage::disk($disk); $this->originalPaths['disks'][$disk] = $root;
$this->originalPaths['disks'][$disk] = $filesystemDisk->getAdapter()->getPathPrefix();
if ($root = str_replace( if (!$root = str_replace(
'%storage_path%', '%storage_path%',
storage_path(), storage_path(),
$this->app['config']["tenancy.filesystem.root_override.{$disk}"] ?? '' $this->app['config']["tenancy.filesystem.root_override.{$disk}"] ?? ''
)) { )) {
$filesystemDisk->getAdapter()->setPathPrefix($finalPrefix = $root); $root .= '/' . $suffix;
} else {
$root = $this->app['config']["filesystems.disks.{$disk}.root"];
$filesystemDisk->getAdapter()->setPathPrefix($finalPrefix = $root . "/{$suffix}");
} }
$this->app['config']["filesystems.disks.{$disk}.root"] = $finalPrefix; $this->app['config']["filesystems.disks.{$disk}.root"] = $root;
} }
} }
@ -84,13 +81,10 @@ 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']);
foreach ($this->app['config']['tenancy.filesystem.disks'] as $disk) { foreach ($this->app['config']['tenancy.filesystem.disks'] as $disk) {
/** @var FilesystemAdapter $filesystemDisk */
$filesystemDisk = Storage::disk($disk);
$root = $this->originalPaths['disks'][$disk]; $root = $this->originalPaths['disks'][$disk];
$filesystemDisk->getAdapter()->setPathPrefix($root);
$this->app['config']["filesystems.disks.{$disk}.root"] = $root; $this->app['config']["filesystems.disks.{$disk}.root"] = $root;
} }
} }