Skip to content

Commit b1a34d9

Browse files
daniserSergey Danilchenko
andauthored
[12.x] Pass "throw" option from scoped to parent disk (#57163)
Co-authored-by: Sergey Danilchenko <[email protected]>
1 parent 387a9cd commit b1a34d9

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

src/Illuminate/Filesystem/FilesystemManager.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,10 @@ function (&$parent) use ($config) {
313313
if (isset($config['visibility'])) {
314314
$parent['visibility'] = $config['visibility'];
315315
}
316+
317+
if (isset($config['throw'])) {
318+
$parent['throw'] = $config['throw'];
319+
}
316320
}
317321
));
318322
}

tests/Filesystem/FilesystemManagerTest.php

Lines changed: 24 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\UnableToReadFile;
910
use PHPUnit\Framework\Attributes\RequiresOperatingSystem;
1011
use PHPUnit\Framework\TestCase;
1112

@@ -163,6 +164,29 @@ public function testCanBuildScopedDisksWithVisibility()
163164
}
164165
}
165166

167+
public function testCanBuildScopedDisksWithThrow()
168+
{
169+
$filesystem = new FilesystemManager(tap(new Application, function ($app) {
170+
$app['config'] = [
171+
'filesystems.disks.local' => [
172+
'driver' => 'local',
173+
'root' => 'to-be-scoped',
174+
'throw' => false,
175+
],
176+
];
177+
}));
178+
179+
$scoped = $filesystem->build([
180+
'driver' => 'scoped',
181+
'disk' => 'local',
182+
'prefix' => 'path-prefix',
183+
'throw' => true,
184+
]);
185+
186+
$this->expectException(UnableToReadFile::class);
187+
$scoped->get('dirname/filename.txt');
188+
}
189+
166190
public function testCanBuildInlineScopedDisks()
167191
{
168192
try {

0 commit comments

Comments
 (0)