Skip to content

Commit 2664e7f

Browse files
committed
accept optional mode in replace method
1 parent 68a8bfc commit 2664e7f

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/Illuminate/Filesystem/Filesystem.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,9 +195,10 @@ public function put($path, $contents, $lock = false)
195195
*
196196
* @param string $path
197197
* @param string $content
198+
* @param int|null $mode
198199
* @return void
199200
*/
200-
public function replace($path, $content)
201+
public function replace($path, $content, $mode = null)
201202
{
202203
// If the path already exists and is a symlink, get the real path...
203204
clearstatcache(true, $path);
@@ -207,7 +208,11 @@ public function replace($path, $content)
207208
$tempPath = tempnam(dirname($path), basename($path));
208209

209210
// Fix permissions of tempPath because `tempnam()` creates it with permissions set to 0600...
210-
chmod($tempPath, 0777 - umask());
211+
if (! is_null($mode)) {
212+
chmod($tempPath, $mode);
213+
} else {
214+
chmod($tempPath, 0777 - umask());
215+
}
211216

212217
file_put_contents($tempPath, $content);
213218

0 commit comments

Comments
 (0)