|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Spatie\Export; |
|
4
|
|
|
|
|
5
|
|
|
use Spatie\Export\Jobs\CrawlSite; |
|
6
|
|
|
use Illuminate\Contracts\Bus\Dispatcher; |
|
7
|
|
|
use Spatie\Export\Jobs\CleanDestination; |
|
8
|
|
|
use Spatie\Export\Jobs\cleanBeforeExportDestination; |
|
9
|
|
|
|
|
10
|
|
|
class Exporter |
|
11
|
|
|
{ |
|
12
|
|
|
/** @var \Illuminate\Contracts\Bus\Dispatcher */ |
|
13
|
|
|
protected $dispatcher; |
|
14
|
|
|
|
|
15
|
|
|
/** @var boolean */ |
|
16
|
|
|
protected $cleanBeforeExport = false; |
|
17
|
|
|
|
|
18
|
|
|
/** @var boolean */ |
|
19
|
|
|
protected $crawl = false; |
|
20
|
|
|
|
|
21
|
|
|
/** @var string[] */ |
|
22
|
|
|
protected $paths = []; |
|
23
|
|
|
|
|
24
|
|
|
/** @var string[] */ |
|
25
|
|
|
protected $rewriteRules = []; |
|
26
|
|
|
|
|
27
|
|
|
/** @var string[] */ |
|
28
|
|
|
protected $includeFiles = []; |
|
29
|
|
|
|
|
30
|
|
|
/** @var string[] */ |
|
31
|
|
|
protected $excludeFilePatterns = []; |
|
32
|
|
|
|
|
33
|
|
|
public function __construct(Dispatcher $dispatcher) |
|
34
|
|
|
{ |
|
35
|
|
|
$this->dispatcher = $dispatcher; |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
public function cleanBeforeExport(bool $cleanBeforeExport): self |
|
39
|
|
|
{ |
|
40
|
|
|
$this->cleanBeforeExport = $cleanBeforeExport; |
|
41
|
|
|
|
|
42
|
|
|
return $this; |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
public function crawl(bool $crawl): self |
|
46
|
|
|
{ |
|
47
|
|
|
$this->crawl = $crawl; |
|
48
|
|
|
|
|
49
|
|
|
return $this; |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
public function paths(array $paths): self |
|
53
|
|
|
{ |
|
54
|
|
|
$this->paths = array_merge($this->paths, $paths); |
|
|
|
|
|
|
55
|
|
|
|
|
56
|
|
|
return $this; |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
public function rewriteRules(array $rewriteRules): self |
|
60
|
|
|
{ |
|
61
|
|
|
$this->rewriteRules = array_merge($this->rewriteRules, $rewriteRules); |
|
|
|
|
|
|
62
|
|
|
|
|
63
|
|
|
return $this; |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
public function includeFiles(array $includeFiles): self |
|
67
|
|
|
{ |
|
68
|
|
|
$this->includeFiles = array_merge($this->includeFiles, $includeFiles); |
|
|
|
|
|
|
69
|
|
|
|
|
70
|
|
|
return $this; |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
public function excludeFilePatterns(array $excludeFilePatterns): self |
|
74
|
|
|
{ |
|
75
|
|
|
$this->excludeFilePatterns = array_merge($this->excludeFilePatterns, $excludeFilePatterns); |
|
|
|
|
|
|
76
|
|
|
|
|
77
|
|
|
return $this; |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
public function export() |
|
81
|
|
|
{ |
|
82
|
|
|
if ($this->cleanBeforeExport) { |
|
83
|
|
|
$this->dispatcher->dispatchNow(new CleanDestination()); |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
if ($this->crawl) { |
|
87
|
|
|
$this->dispatcher->dispatchNow(new CrawlSite()); |
|
88
|
|
|
} |
|
89
|
|
|
} |
|
90
|
|
|
} |
|
91
|
|
|
|
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..