Skip to content

Commit

Permalink
pass visibility from scoped disk to parent (#48186)
Browse files Browse the repository at this point in the history
  • Loading branch information
okaufmann authored Aug 25, 2023
1 parent 9d7244c commit 3365194
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/Illuminate/Filesystem/FilesystemManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,13 @@ public function createScopedDriver(array $config)

return $this->build(tap(
is_string($config['disk']) ? $this->getConfig($config['disk']) : $config['disk'],
fn (&$parent) => $parent['prefix'] = $config['prefix']
function (&$parent) use ($config) {
$parent['prefix'] = $config['prefix'];

if (isset($config['visibility'])) {
$parent['visibility'] = $config['visibility'];
}
}
));
}

Expand Down
34 changes: 34 additions & 0 deletions tests/Filesystem/FilesystemManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,40 @@ public function testCanBuildScopedDisks()
}
}

/**
* @requires OS Linux|Darwin
*/
public function testCanBuildScopedDisksWithVisibility()
{
try {
$filesystem = new FilesystemManager(tap(new Application, function ($app) {
$app['config'] = [
'filesystems.disks.local' => [
'driver' => 'local',
'root' => 'to-be-scoped',
'visibility' => 'public',
],
];
}));

$scoped = $filesystem->build([
'driver' => 'scoped',
'disk' => 'local',
'prefix' => 'path-prefix',
'visibility' => 'private',
]);

$scoped->put('dirname/filename.txt', 'file content');

$this->assertEquals('private', $scoped->getVisibility('dirname/filename.txt'));
} finally {
unlink(__DIR__.'/../../to-be-scoped/path-prefix/dirname/filename.txt');
rmdir(__DIR__.'/../../to-be-scoped/path-prefix/dirname');
rmdir(__DIR__.'/../../to-be-scoped/path-prefix');
rmdir(__DIR__.'/../../to-be-scoped');
}
}

public function testCanBuildInlineScopedDisks()
{
try {
Expand Down

0 comments on commit 3365194

Please sign in to comment.