@@ -62,8 +62,7 @@ |
||
62 | 62 | * |
63 | 63 | * @return \Illuminate\Database\Eloquent\Relations\HasMany |
64 | 64 | */ |
65 | - public function translations() |
|
66 | - { |
|
65 | + public function translations() { |
|
67 | 66 | return $this->hasMany(Translations::class); |
68 | 67 | } |
69 | 68 |
@@ -16,21 +16,27 @@ |
||
16 | 16 | * |
17 | 17 | * Class TranslationNotFoundException |
18 | 18 | */ |
19 | -class TranslationNotFoundException extends \Exception {} |
|
19 | +class TranslationNotFoundException extends \Exception |
|
20 | +{ |
|
21 | +} |
|
20 | 22 | |
21 | 23 | /** |
22 | 24 | * Custom Exception to distinguish if the Translation Identifier was not found in Cache but could be in DB |
23 | 25 | * |
24 | 26 | * Class TranslationNotInCacheException |
25 | 27 | */ |
26 | -class TranslationNotInCacheException extends TranslationNotFoundException {} |
|
28 | +class TranslationNotInCacheException extends TranslationNotFoundException |
|
29 | +{ |
|
30 | +} |
|
27 | 31 | |
28 | 32 | /** |
29 | 33 | * Custom Exception thrown when a cache file could not be found |
30 | 34 | * |
31 | 35 | * Class TranslationCacheNotFound |
32 | 36 | */ |
33 | -class TranslationCacheNotFound extends \Exception {} |
|
37 | +class TranslationCacheNotFound extends \Exception |
|
38 | +{ |
|
39 | +} |
|
34 | 40 | |
35 | 41 | /** |
36 | 42 | * Interface HandlerInterface |
@@ -36,15 +36,13 @@ discard block |
||
36 | 36 | * @throws TranslationNotInCacheException |
37 | 37 | * @return string returns the found translation for locale and identifier |
38 | 38 | */ |
39 | - public function getTranslation($identifier, $group = 'default') |
|
40 | - { |
|
39 | + public function getTranslation($identifier, $group = 'default') { |
|
41 | 40 | // NOTE: This should never trigger the addition of the identifier to the database! |
42 | 41 | // Because the cache will not be updated automatically. |
43 | 42 | // the same identifier will not be found twice in the cache, which will result in a duplicate key sql error. |
44 | 43 | if (isset($this->translations[$group][$identifier])) { |
45 | 44 | return $this->translations[$group][$identifier]; |
46 | - } |
|
47 | - else { |
|
45 | + } else { |
|
48 | 46 | throw new TranslationNotInCacheException("The translation identifier '" . $identifier . "' could not be found in Cache"); |
49 | 47 | } |
50 | 48 | } |
@@ -55,8 +53,7 @@ discard block |
||
55 | 53 | * @param string $group |
56 | 54 | * @throws TranslationCacheNotFound |
57 | 55 | */ |
58 | - public function refreshCache($group = 'default') |
|
59 | - { |
|
56 | + public function refreshCache($group = 'default') { |
|
60 | 57 | $locale_dir = TranslatorFacade::getConfigValue('cache_path') . $this->locale; |
61 | 58 | |
62 | 59 | try { |
@@ -22,8 +22,7 @@ discard block |
||
22 | 22 | /** |
23 | 23 | * Register any application services. |
24 | 24 | */ |
25 | - public function register() |
|
26 | - { |
|
25 | + public function register() { |
|
27 | 26 | $this->mergeConfigFrom(__DIR__ . '/../config/translator.php', 'translator'); |
28 | 27 | |
29 | 28 | $this->app->singleton('Translator', function() { |
@@ -35,8 +34,7 @@ discard block |
||
35 | 34 | /** |
36 | 35 | * Bootstrap any application services. |
37 | 36 | */ |
38 | - public function boot() |
|
39 | - { |
|
37 | + public function boot() { |
|
40 | 38 | $this->publishes([ |
41 | 39 | __DIR__ . '/../config/translator.php' => config_path('translator.php'), |
42 | 40 | ], |
@@ -27,16 +27,14 @@ |
||
27 | 27 | * |
28 | 28 | * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View |
29 | 29 | */ |
30 | - public function index() |
|
31 | - { |
|
30 | + public function index() { |
|
32 | 31 | $search = Input::get('search', ''); |
33 | 32 | $locale = Input::get('locale', ''); |
34 | 33 | |
35 | 34 | $query = TranslationIdentifier::with('translations'); |
36 | 35 | |
37 | 36 | if ($locale != '') { |
38 | - $query = $query->whereDoesntHave('translations', function($query) use ($locale) |
|
39 | - { |
|
37 | + $query = $query->whereDoesntHave('translations', function($query) use ($locale) { |
|
40 | 38 | $query->where('translations.locale', 'like', $locale); |
41 | 39 | } |
42 | 40 | ); |
@@ -107,12 +107,10 @@ |
||
107 | 107 | * @param string $locale The locale from which the translations to load |
108 | 108 | * @return TranslationIdentifier|\Illuminate\Database\Eloquent\Collection|static[] |
109 | 109 | */ |
110 | - protected function loadFromDB($locale) |
|
111 | - { |
|
110 | + protected function loadFromDB($locale) { |
|
112 | 111 | $trans_identifier = new TranslationIdentifier(); |
113 | 112 | |
114 | - $trans_identifier = $trans_identifier->with('translations')->whereHas('translations', function($item) use ($locale) |
|
115 | - { |
|
113 | + $trans_identifier = $trans_identifier->with('translations')->whereHas('translations', function($item) use ($locale) { |
|
116 | 114 | return $item->where('locale', $locale); |
117 | 115 | } |
118 | 116 | )->orWhereHas('translations', null, '<=', 0) |
@@ -53,11 +53,9 @@ discard block |
||
53 | 53 | * |
54 | 54 | * @return void |
55 | 55 | */ |
56 | - public function refreshCache() |
|
57 | - { |
|
56 | + public function refreshCache() { |
|
58 | 57 | $translations = new TranslationIdentifier(); |
59 | - $translations = $translations->leftJoin('translations', function($join) |
|
60 | - { |
|
58 | + $translations = $translations->leftJoin('translations', function($join) { |
|
61 | 59 | $join->on('translation_identifiers.id', '=', 'translations.translation_identifier_id') |
62 | 60 | ->where('locale', $this->locale); |
63 | 61 | } |
@@ -93,8 +91,7 @@ discard block |
||
93 | 91 | * @throws NotFoundResourceException |
94 | 92 | * @return integer |
95 | 93 | */ |
96 | - function getDatabaseID($identifier) |
|
97 | - { |
|
94 | + function getDatabaseID($identifier) { |
|
98 | 95 | if (isset($this->translations[$identifier])) { |
99 | 96 | return $this->translations[$identifier]->id; |
100 | 97 | } else { |