Skip to content

Commit 784d1f8

Browse files
Merge pull request #33 from CedsTrash/feature/merge-config-files
Merge default config with user-defined config for User pipeline
2 parents 88a4a0c + 4fb46b1 commit 784d1f8

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/Pipes/Users.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@
66

77
use Closure;
88
use Illuminate\Support\Facades\File;
9+
use Illuminate\Support\Facades\Log;
910
use Itiden\Backup\Abstracts\BackupPipe;
1011
use Itiden\Backup\Support\Zipper;
12+
use RuntimeException;
13+
use Statamic\Facades\Stache;
1114

1215
class Users extends BackupPipe
1316
{
@@ -18,7 +21,7 @@ public static function getKey(): string
1821

1922
public function restore(string $restoringFromPath, Closure $next)
2023
{
21-
$destination = config('statamic.stache.stores.users.directory');
24+
$destination = Stache::store('users')?->directory();
2225
$users = $this->getDirectoryPath($restoringFromPath);
2326

2427
File::copyDirectory($users, $destination);
@@ -28,7 +31,13 @@ public function restore(string $restoringFromPath, Closure $next)
2831

2932
public function backup(Zipper $zip, Closure $next)
3033
{
31-
$zip->addDirectory(config('statamic.stache.stores.users.directory'), static::getKey());
34+
$usersDir = Stache::store('users')?->directory();
35+
36+
if (!$usersDir) {
37+
throw new RuntimeException('Users directory not found');
38+
}
39+
40+
$zip->addDirectory($usersDir, static::getKey());
3241

3342
return $next($zip);
3443
}

0 commit comments

Comments
 (0)