1 | <?php |
||
10 | class SquantoTranslator extends LaravelTranslator implements Translator |
||
11 | { |
||
12 | private $databaseTranslator; |
||
13 | 46 | ||
14 | private $keyAsDefault = true; |
||
15 | 46 | private $isDatabaseAlreadyMigrated = null; |
|
16 | 46 | ||
17 | 47 | public function setKeyAsDefault($keyAsDefault = true) |
|
21 | |||
22 | /** |
||
23 | * Get the translation for the given key by following this priority chain: |
||
24 | * |
||
25 | * 1. Get from our cached translations |
||
26 | * 2. Get from database |
||
27 | * 3. Get from the /resources/lang |
||
28 | * |
||
29 | * @param string $key |
||
30 | * @param array $replace |
||
31 | 14 | * @param string $locale |
|
32 | * @param bool $fallback |
||
33 | 14 | * @return string |
|
34 | */ |
||
35 | 23 | public function get($key, array $replace = array(), $locale = null, $fallback = true) |
|
55 | |||
56 | 14 | /** |
|
57 | * Get from excluded sources. This is used here to make retrieval of these |
||
58 | 14 | * non-managed translations a lot faster by going straight to source |
|
59 | 14 | * |
|
60 | * @param $key |
||
61 | * @param $replace |
||
62 | 14 | * @param $locale |
|
63 | * @param $fallback |
||
64 | 14 | * @return array|null|string |
|
65 | */ |
||
66 | 9 | private function getFromExcludedSource($key, $replace, $locale, $fallback) |
|
72 | |||
73 | 8 | /** |
|
74 | * Retrieve the translation from the squanto cache. |
||
75 | * |
||
76 | * @param $key |
||
77 | * @param array $replace |
||
78 | * @param null $locale |
||
79 | * @return mixed|null |
||
80 | */ |
||
81 | 9 | private function getFromCache($key, array $replace = array(), $locale = null, $fallback = true) |
|
91 | |||
92 | 4 | private function getFromDatabase($key, array $replace = array(), $locale = null, $fallback = true) |
|
107 | |||
108 | /** |
||
109 | * Verify that SQUANTO migrations are already run and present in this environment |
||
110 | * Allow for a soft install |
||
111 | * |
||
112 | * @return null |
||
113 | */ |
||
114 | 4 | private function isDatabaseAlreadyMigrated() |
|
122 | } |
||
123 |
This check looks for a call to a parent method whose name is different than the method from which it is called.
Consider the following code:
The
getFirstName()
method in theSon
calls the wrong method in the parent class.