3
3
namespace Spatie \Backup \Tasks \Backup ;
4
4
5
5
use Illuminate \Support \Str ;
6
+ use Spatie \Backup \Config \Config ;
6
7
use Spatie \Backup \Helpers \Format ;
7
8
use ZipArchive ;
8
9
@@ -12,10 +13,23 @@ class Zip
12
13
13
14
protected int $ fileCount = 0 ;
14
15
16
+ protected Config $ config ;
17
+
18
+ public function __construct (protected string $ pathToZip )
19
+ {
20
+ $ this ->zipFile = new ZipArchive ();
21
+ $ this ->config = app (Config::class);
22
+
23
+ $ this ->open ();
24
+ }
25
+
15
26
public static function createForManifest (Manifest $ manifest , string $ pathToZip ): self
16
27
{
17
- $ relativePath = config ('backup.backup.source.files.relative_path ' ) ?
18
- rtrim ((string ) config ('backup.backup.source.files.relative_path ' ), DIRECTORY_SEPARATOR ).DIRECTORY_SEPARATOR : false ;
28
+ $ config = app (Config::class);
29
+
30
+ $ relativePath = $ config ->backup ->source ->files ->relativePath
31
+ ? rtrim ($ config ->backup ->source ->files ->relativePath , DIRECTORY_SEPARATOR ).DIRECTORY_SEPARATOR
32
+ : false ;
19
33
20
34
$ zip = new static ($ pathToZip );
21
35
@@ -47,13 +61,6 @@ protected static function determineNameOfFileInZip(string $pathToFile, string $p
47
61
return $ pathToFile ;
48
62
}
49
63
50
- public function __construct (protected string $ pathToZip )
51
- {
52
- $ this ->zipFile = new ZipArchive ();
53
-
54
- $ this ->open ();
55
- }
56
-
57
64
public function path (): string
58
65
{
59
66
return $ this ->pathToZip ;
@@ -93,8 +100,8 @@ public function add(string|iterable $files, ?string $nameInZip = null): self
93
100
$ files = [$ files ];
94
101
}
95
102
96
- $ compressionMethod = config ( ' backup.backup. destination.compression_method ' , null ) ;
97
- $ compressionLevel = config ( ' backup.backup. destination.compression_level ' , 9 ) ;
103
+ $ compressionMethod = $ this -> config -> backup -> destination -> compressionMethod ;
104
+ $ compressionLevel = $ this -> config -> backup -> destination -> compressionLevel ;
98
105
99
106
foreach ($ files as $ file ) {
100
107
if (is_dir ($ file )) {
0 commit comments