Skip to content

Commit f9e75e7

Browse files
daniserSergey Danilchenko
andauthored
[12.x] Track filesystem adapter decoration (#57167)
Co-authored-by: Sergey Danilchenko <[email protected]>
1 parent 0f985d3 commit f9e75e7

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

src/Illuminate/Filesystem/FilesystemManager.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ function (&$parent) use ($config) {
328328
* @param array $config
329329
* @return \League\Flysystem\FilesystemOperator
330330
*/
331-
protected function createFlysystem(FlysystemAdapter $adapter, array $config)
331+
protected function createFlysystem(FlysystemAdapter &$adapter, array $config)
332332
{
333333
if (($config['read-only'] ?? false) === true) {
334334
$adapter = new ReadOnlyFilesystemAdapter($adapter);

tests/Filesystem/FilesystemManagerTest.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Illuminate\Filesystem\FilesystemManager;
77
use Illuminate\Foundation\Application;
88
use InvalidArgumentException;
9+
use League\Flysystem\PathPrefixing\PathPrefixedAdapter;
910
use League\Flysystem\UnableToReadFile;
1011
use PHPUnit\Framework\Attributes\RequiresOperatingSystem;
1112
use PHPUnit\Framework\TestCase;
@@ -211,4 +212,24 @@ public function testCanBuildInlineScopedDisks()
211212
rmdir(__DIR__.'/../../to-be-scoped');
212213
}
213214
}
215+
216+
public function testKeepTrackOfAdapterDecoration()
217+
{
218+
$filesystem = new FilesystemManager(tap(new Application, function ($app) {
219+
$app['config'] = [
220+
'filesystems.disks.local' => [
221+
'driver' => 'local',
222+
'root' => 'to-be-scoped',
223+
],
224+
];
225+
}));
226+
227+
$scoped = $filesystem->build([
228+
'driver' => 'scoped',
229+
'disk' => 'local',
230+
'prefix' => 'path-prefix',
231+
]);
232+
233+
$this->assertInstanceOf(PathPrefixedAdapter::class, $scoped->getAdapter());
234+
}
214235
}

0 commit comments

Comments
 (0)