Skip to content

Commit 3365194

Browse files
authored
pass visibility from scoped disk to parent (#48186)
1 parent 9d7244c commit 3365194

File tree

2 files changed

+41
-1
lines changed

2 files changed

+41
-1
lines changed

src/Illuminate/Filesystem/FilesystemManager.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,13 @@ public function createScopedDriver(array $config)
285285

286286
return $this->build(tap(
287287
is_string($config['disk']) ? $this->getConfig($config['disk']) : $config['disk'],
288-
fn (&$parent) => $parent['prefix'] = $config['prefix']
288+
function (&$parent) use ($config) {
289+
$parent['prefix'] = $config['prefix'];
290+
291+
if (isset($config['visibility'])) {
292+
$parent['visibility'] = $config['visibility'];
293+
}
294+
}
289295
));
290296
}
291297

tests/Filesystem/FilesystemManagerTest.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,40 @@ public function testCanBuildScopedDisks()
9898
}
9999
}
100100

101+
/**
102+
* @requires OS Linux|Darwin
103+
*/
104+
public function testCanBuildScopedDisksWithVisibility()
105+
{
106+
try {
107+
$filesystem = new FilesystemManager(tap(new Application, function ($app) {
108+
$app['config'] = [
109+
'filesystems.disks.local' => [
110+
'driver' => 'local',
111+
'root' => 'to-be-scoped',
112+
'visibility' => 'public',
113+
],
114+
];
115+
}));
116+
117+
$scoped = $filesystem->build([
118+
'driver' => 'scoped',
119+
'disk' => 'local',
120+
'prefix' => 'path-prefix',
121+
'visibility' => 'private',
122+
]);
123+
124+
$scoped->put('dirname/filename.txt', 'file content');
125+
126+
$this->assertEquals('private', $scoped->getVisibility('dirname/filename.txt'));
127+
} finally {
128+
unlink(__DIR__.'/../../to-be-scoped/path-prefix/dirname/filename.txt');
129+
rmdir(__DIR__.'/../../to-be-scoped/path-prefix/dirname');
130+
rmdir(__DIR__.'/../../to-be-scoped/path-prefix');
131+
rmdir(__DIR__.'/../../to-be-scoped');
132+
}
133+
}
134+
101135
public function testCanBuildInlineScopedDisks()
102136
{
103137
try {

0 commit comments

Comments
 (0)