@@ -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 { |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * Bootstrap any application services. |
24 | 24 | */ |
25 | 25 | public function boot() { |
26 | - Blade::directive('translate', function ($expression) { |
|
26 | + Blade::directive('translate', function($expression) { |
|
27 | 27 | |
28 | 28 | $expression = $this->stripParentheses($expression); |
29 | 29 | |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | } |
33 | 33 | ); |
34 | 34 | |
35 | - Blade::directive('t', function ($expression) { |
|
35 | + Blade::directive('t', function($expression) { |
|
36 | 36 | |
37 | 37 | $expression = $this->stripParentheses($expression); |
38 | 38 |
@@ -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 | ], |
@@ -164,7 +164,7 @@ |
||
164 | 164 | * @param $state string 'enabled|disabled' |
165 | 165 | * @return \Illuminate\Http\RedirectResponse |
166 | 166 | */ |
167 | - public function changeLiveMode ($state) { |
|
167 | + public function changeLiveMode($state) { |
|
168 | 168 | if ($state == 'enable') { |
169 | 169 | session(['translation_live_mode' => true]); |
170 | 170 | } else { |
@@ -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 | ); |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | DB::beginTransaction(); |
26 | 26 | |
27 | 27 | // Create table for storing roles |
28 | - Schema::create('translation_identifiers', function (Blueprint $table) { |
|
28 | + Schema::create('translation_identifiers', function(Blueprint $table) { |
|
29 | 29 | $table->increments('id')->unique(); |
30 | 30 | $table->text('identifier'); |
31 | 31 | |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | }); |
40 | 40 | |
41 | 41 | // Create table for storing roles |
42 | - Schema::create('translations', function (Blueprint $table) { |
|
42 | + Schema::create('translations', function(Blueprint $table) { |
|
43 | 43 | $table->integer('translation_identifier_id')->unsigned(); |
44 | 44 | $table->foreign('translation_identifier_id')->references('id')->on('translation_identifiers')->onDelete('no action')->onUpdate('no action'); |
45 | 45 |
@@ -182,7 +182,7 @@ |
||
182 | 182 | |
183 | 183 | $keys = []; |
184 | 184 | if (is_array($parameters)) { |
185 | - foreach($parameters as $key => $value) { |
|
185 | + foreach ($parameters as $key => $value) { |
|
186 | 186 | $keys[] = $key; |
187 | 187 | } |
188 | 188 | } |
@@ -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) |