1 | <?php namespace Arcanedev\Settings\Stores; |
||
15 | class JsonStore extends Store implements StoreContract |
||
16 | { |
||
17 | /* ------------------------------------------------------------------------------------------------ |
||
18 | | Properties |
||
19 | | ------------------------------------------------------------------------------------------------ |
||
20 | */ |
||
21 | /** |
||
22 | * The Filesystem instance. |
||
23 | * |
||
24 | * @var \Illuminate\Filesystem\Filesystem |
||
25 | */ |
||
26 | protected $files; |
||
27 | |||
28 | /** |
||
29 | * The json file path. |
||
30 | * |
||
31 | * @var string |
||
32 | */ |
||
33 | protected $path; |
||
34 | |||
35 | /* ------------------------------------------------------------------------------------------------ |
||
36 | | Constructor |
||
37 | | ------------------------------------------------------------------------------------------------ |
||
38 | */ |
||
39 | /** |
||
40 | * Make the Json store instance. |
||
41 | * |
||
42 | * @param \Illuminate\Filesystem\Filesystem $files |
||
43 | * @param string $path |
||
44 | */ |
||
45 | 39 | public function __construct(Filesystem $files, $path = null) |
|
46 | { |
||
47 | 39 | $this->files = $files; |
|
48 | 39 | $this->setPath($path ?: storage_path('app/settings.json')); |
|
49 | 39 | } |
|
50 | |||
51 | /* ------------------------------------------------------------------------------------------------ |
||
52 | | Getters & Setters |
||
53 | | ------------------------------------------------------------------------------------------------ |
||
54 | */ |
||
55 | /** |
||
56 | * Set the path for the JSON file. |
||
57 | * |
||
58 | * @param string $path |
||
59 | * |
||
60 | * @return self |
||
61 | */ |
||
62 | 39 | public function setPath($path) |
|
79 | |||
80 | /* ------------------------------------------------------------------------------------------------ |
||
81 | | Other Functions |
||
82 | | ------------------------------------------------------------------------------------------------ |
||
83 | */ |
||
84 | /** |
||
85 | * {@inheritdoc} |
||
86 | */ |
||
87 | 24 | protected function read() |
|
99 | |||
100 | /** |
||
101 | * {@inheritdoc} |
||
102 | */ |
||
103 | 15 | protected function write(array $data) |
|
109 | } |
||
110 |