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 | * All of the namespace hints. |
||
48 | * |
||
49 | * @var array |
||
50 | */ |
||
51 | protected $hints = []; |
||
52 | |||
53 | /** |
||
54 | * The cache repository. |
||
55 | * |
||
56 | * @var TranslationRepository |
||
57 | */ |
||
58 | protected $translationRepository; |
||
59 | |||
60 | /** |
||
61 | * The cache repository. |
||
62 | * |
||
63 | * @var FileLoader |
||
64 | */ |
||
65 | protected $laravelFileLoader; |
||
66 | |||
67 | /** |
||
68 | * DatabaseLoader constructor. |
||
69 | * |
||
70 | * @param Filesystem $filesystem |
||
71 | * @param $path |
||
72 | * @param TranslationRepository $translationRepository |
||
73 | * @param CacheRepository $cache |
||
74 | */ |
||
75 | public function __construct( |
||
91 | |||
92 | /** |
||
93 | * Load the messages for the given locale. |
||
94 | * |
||
95 | * @param string $locale |
||
96 | * @param string $group |
||
97 | * @param string $namespace |
||
98 | * |
||
99 | * @return array |
||
100 | */ |
||
101 | public function load($locale, $group, $namespace = null) : array |
||
115 | |||
116 | /** |
||
117 | * Get the messages for the given locale from the database and merge |
||
118 | * them with the file based ones as a fallback for a given locale. |
||
119 | * |
||
120 | * @param string $locale |
||
121 | * @param string $group |
||
122 | * @param string $namespace |
||
123 | * |
||
124 | * @return array |
||
125 | */ |
||
126 | protected function loadCombinedTranslations($locale, $group, $namespace) : array |
||
133 | |||
134 | /** |
||
135 | * Add a new namespace to the loader. |
||
136 | * |
||
137 | * @param string $namespace |
||
138 | * @param string $hint |
||
139 | * |
||
140 | * @return void |
||
141 | */ |
||
142 | public function addNamespace($namespace, $hint) |
||
147 | |||
148 | /** |
||
149 | * Get an array of all the registered namespaces. |
||
150 | * |
||
151 | * @return array |
||
152 | */ |
||
153 | public function namespaces() : array |
||
157 | |||
158 | /** |
||
159 | * Load the required translations from the database. |
||
160 | * |
||
161 | * @param string $locale |
||
162 | * @param string $group |
||
163 | * @param string $namespace |
||
164 | * |
||
165 | * @return array |
||
166 | */ |
||
167 | protected function loadFromDatabase($locale, $group, $namespace) : array |
||
175 | |||
176 | /** |
||
177 | * Load a non-namespaced translation group. |
||
178 | * |
||
179 | * @param string $locale |
||
180 | * @param string $group |
||
181 | * |
||
182 | * @return array |
||
183 | */ |
||
184 | protected function loadGroup($locale, $group) : array |
||
190 | |||
191 | /** |
||
192 | * Load a namespaced translation group. |
||
193 | * |
||
194 | * @param string $locale |
||
195 | * @param string $group |
||
196 | * @param string $namespace |
||
197 | * |
||
198 | * @return array |
||
199 | */ |
||
200 | protected function loadNamespaced($locale, $namespace, $group) : array |
||
206 | |||
207 | /** |
||
208 | * Create a formatted array as if it was coming from the default loader. |
||
209 | * |
||
210 | * @param Collection $translations |
||
211 | * @param string $locale |
||
212 | * |
||
213 | * @return array |
||
214 | */ |
||
215 | protected function createFormattedArray($translations, $locale) : array |
||
231 | |||
232 | /** |
||
233 | * Get the Laravel File loader. |
||
234 | * |
||
235 | * @return FileLoader |
||
236 | */ |
||
237 | public function getFileLoader() : FileLoader |
||
241 | } |
||
242 |