1 | <?php |
||
9 | class SquantoTranslator extends LaravelTranslator implements Translator |
||
10 | { |
||
11 | private $databaseTranslator; |
||
12 | |||
13 | 69 | private $keyAsDefault = true; |
|
14 | private $isDatabaseAlreadyMigrated = null; |
||
15 | 69 | ||
16 | 69 | public function setKeyAsDefault($keyAsDefault = true) |
|
20 | |||
21 | /** |
||
22 | * Get the translation for the given key by following this priority chain: |
||
23 | * |
||
24 | * 1. Get from our cached translations |
||
25 | * 2. Get from database |
||
26 | * 3. Get from the /resources/lang |
||
27 | * |
||
28 | * @param string $key |
||
29 | * @param array $replace |
||
30 | * @param string $locale |
||
31 | 21 | * @param bool $fallback |
|
32 | * @return string |
||
33 | 21 | */ |
|
34 | public function get($key, array $replace = array(), $locale = null, $fallback = true) |
||
54 | |||
55 | /** |
||
56 | 21 | * Get from excluded sources. This is used here to make retrieval of these |
|
57 | * non-managed translations a lot faster by going straight to source |
||
58 | 21 | * |
|
59 | 21 | * @param $key |
|
60 | * @param $replace |
||
61 | * @param $locale |
||
62 | 21 | * @param $fallback |
|
63 | * @return array|null|string |
||
64 | 21 | */ |
|
65 | private function getFromExcludedSource($key, $replace, $locale, $fallback) |
||
71 | |||
72 | /** |
||
73 | 12 | * Retrieve the translation from the squanto cache. |
|
74 | * |
||
75 | * @param $key |
||
76 | * @param array $replace |
||
77 | * @param null $locale |
||
78 | * @return mixed|null |
||
79 | */ |
||
80 | private function getFromCache($key, array $replace = array(), $locale = null, $fallback = true) |
||
90 | |||
91 | private function getFromDatabase($key, array $replace = array(), $locale = null, $fallback = true) |
||
106 | |||
107 | /** |
||
108 | * Verify that SQUANTO migrations are already run and present in this environment |
||
109 | * Allow for a soft install |
||
110 | * |
||
111 | * @return null |
||
112 | */ |
||
113 | private function isDatabaseAlreadyMigrated() |
||
121 | } |
||
122 |
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.