1 | <?php |
||
16 | class DatabaseLoader implements LoaderInterface |
||
17 | { |
||
18 | /** |
||
19 | * The filesystem instance. |
||
20 | * |
||
21 | * @var \Illuminate\Filesystem\Filesystem |
||
22 | */ |
||
23 | protected $files; |
||
24 | |||
25 | /** |
||
26 | * The default path for the loader. |
||
27 | * |
||
28 | * @var string |
||
29 | */ |
||
30 | protected $path; |
||
31 | |||
32 | /** |
||
33 | * The cache repository. |
||
34 | * |
||
35 | * @var CacheRepository |
||
36 | */ |
||
37 | protected $cache; |
||
38 | |||
39 | /** |
||
40 | * Is cache enabled. |
||
41 | * |
||
42 | * @var bool |
||
43 | */ |
||
44 | protected $cacheEnabled; |
||
45 | |||
46 | |||
47 | /** |
||
48 | * All of the namespace hints. |
||
49 | * |
||
50 | * @var array |
||
51 | */ |
||
52 | protected $hints = []; |
||
53 | |||
54 | /** |
||
55 | * The cache repository. |
||
56 | * |
||
57 | * @var TranslationRepository |
||
58 | */ |
||
59 | protected $translationRepository; |
||
60 | |||
61 | /** |
||
62 | * The cache repository. |
||
63 | * |
||
64 | * @var FileLoader |
||
65 | */ |
||
66 | protected $laravelFileLoader; |
||
67 | |||
68 | /** |
||
69 | * DatabaseLoader constructor. |
||
70 | * |
||
71 | * @param Filesystem $filesystem |
||
72 | * @param $path |
||
73 | * @param TranslationRepository $translationRepository |
||
74 | * @param CacheRepository $cache |
||
75 | */ |
||
76 | public function __construct( |
||
92 | |||
93 | /** |
||
94 | * Load the messages for the given locale. |
||
95 | * |
||
96 | * @param string $locale |
||
97 | * @param string $group |
||
98 | * @param string $namespace |
||
99 | * |
||
100 | * @return array |
||
101 | */ |
||
102 | public function load($locale, $group, $namespace = null) : array |
||
116 | |||
117 | /** |
||
118 | * Get the messages for the given locale from the database and merge |
||
119 | * them with the file based ones as a fallback for a given locale. |
||
120 | * |
||
121 | * @param string $locale |
||
122 | * @param string $group |
||
123 | * @param string $namespace |
||
124 | * |
||
125 | * @return array |
||
126 | */ |
||
127 | protected function loadCombinedTranslations($locale, $group, $namespace) : array |
||
134 | |||
135 | /** |
||
136 | * Add a new namespace to the loader. |
||
137 | * |
||
138 | * @param string $namespace |
||
139 | * @param string $hint |
||
140 | * |
||
141 | * @return void |
||
142 | */ |
||
143 | public function addNamespace($namespace, $hint) |
||
148 | |||
149 | /** |
||
150 | * Get an array of all the registered namespaces. |
||
151 | * |
||
152 | * @return array |
||
153 | */ |
||
154 | public function namespaces() : array |
||
158 | |||
159 | /** |
||
160 | * Load the required translations from the database. |
||
161 | * |
||
162 | * @param string $locale |
||
163 | * @param string $group |
||
164 | * @param string $namespace |
||
165 | * |
||
166 | * @return array |
||
167 | */ |
||
168 | protected function loadFromDatabase($locale, $group, $namespace) : array |
||
176 | |||
177 | /** |
||
178 | * Load a non-namespaced translation group. |
||
179 | * |
||
180 | * @param string $locale |
||
181 | * @param string $group |
||
182 | * |
||
183 | * @return array |
||
184 | */ |
||
185 | protected function loadGroup($locale, $group) : array |
||
191 | |||
192 | /** |
||
193 | * Load a namespaced translation group. |
||
194 | * |
||
195 | * @param string $locale |
||
196 | * @param string $group |
||
197 | * @param string $namespace |
||
198 | * |
||
199 | * @return array |
||
200 | */ |
||
201 | protected function loadNamespaced($locale, $namespace, $group) : array |
||
207 | |||
208 | /** |
||
209 | * Create a formatted array as if it was coming from the default loader. |
||
210 | * |
||
211 | * @param Collection $translations |
||
212 | * @param string $locale |
||
213 | * |
||
214 | * @return array |
||
215 | */ |
||
216 | protected function createFormattedArray($translations, $locale) : array |
||
232 | |||
233 | /** |
||
234 | * Get the Laravel File loader. |
||
235 | * |
||
236 | * @return FileLoader |
||
237 | */ |
||
238 | public function getFileLoader() : FileLoader |
||
242 | } |
||
243 |