|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Facade\Ignition; |
|
4
|
|
|
|
|
5
|
|
|
use Illuminate\Support\Arr; |
|
6
|
|
|
use Illuminate\Contracts\Support\Arrayable; |
|
7
|
|
|
|
|
8
|
|
|
class IgnitionConfig implements Arrayable |
|
9
|
|
|
{ |
|
10
|
|
|
/** @var array */ |
|
11
|
|
|
protected $options; |
|
12
|
|
|
|
|
13
|
|
|
public function __construct(array $options = []) |
|
14
|
|
|
{ |
|
15
|
|
|
$this->options = $this->mergeWithDefaultConfig($options); |
|
16
|
|
|
} |
|
17
|
|
|
|
|
18
|
|
|
public function getEditor(): ?string |
|
19
|
|
|
{ |
|
20
|
|
|
return Arr::get($this->options, 'editor'); |
|
21
|
|
|
} |
|
22
|
|
|
|
|
23
|
|
|
public function getRemoteSitesPath(): ?string |
|
24
|
|
|
{ |
|
25
|
|
|
return Arr::get($this->options, 'remote-sites-path'); |
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
|
|
public function getLocalSitesPath(): ?string |
|
29
|
|
|
{ |
|
30
|
|
|
return Arr::get($this->options, 'local-sites-path'); |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
public function getTheme(): ?string |
|
34
|
|
|
{ |
|
35
|
|
|
return Arr::get($this->options, 'theme'); |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
public function getEnableShareButton(): bool |
|
39
|
|
|
{ |
|
40
|
|
|
return Arr::get($this->options, 'enable_share_button', true); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
public function getEnableRunnableSolutions(): bool |
|
44
|
|
|
{ |
|
45
|
|
|
$enabled = Arr::get($this->options, 'enable_runnable_solutions', null); |
|
46
|
|
|
|
|
47
|
|
|
if ($enabled === null) { |
|
48
|
|
|
$enabled = config('app.debug'); |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
return $enabled ?? false; |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
public function toArray(): array |
|
55
|
|
|
{ |
|
56
|
|
|
return [ |
|
57
|
|
|
'editor' => $this->getEditor(), |
|
58
|
|
|
'remoteSitesPath' => $this->getRemoteSitesPath(), |
|
59
|
|
|
'localSitesPath' => $this->getLocalSitesPath(), |
|
60
|
|
|
'theme' => $this->getTheme(), |
|
61
|
|
|
'enableShareButton' => $this->getEnableShareButton(), |
|
62
|
|
|
'enableRunnableSolutions' => $this->getEnableRunnableSolutions(), |
|
63
|
|
|
'directorySeparator' => DIRECTORY_SEPARATOR, |
|
64
|
|
|
]; |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
protected function mergeWithDefaultConfig(array $options = []): array |
|
68
|
|
|
{ |
|
69
|
|
|
return array_merge(config('ignition'), $options); |
|
70
|
|
|
} |
|
71
|
|
|
} |
|
72
|
|
|
|