1 | <?php namespace Arcanedev\Localization\Middleware; |
||
14 | abstract class Middleware |
||
15 | { |
||
16 | /* ----------------------------------------------------------------- |
||
17 | | Properties |
||
18 | | ----------------------------------------------------------------- |
||
19 | */ |
||
20 | |||
21 | /** |
||
22 | * The localization instance. |
||
23 | * |
||
24 | * @var \Arcanedev\Localization\Contracts\Localization |
||
25 | */ |
||
26 | protected $localization; |
||
27 | |||
28 | /** |
||
29 | * The URIs that should not be localized. |
||
30 | * |
||
31 | * @var array |
||
32 | */ |
||
33 | protected $except = []; |
||
34 | |||
35 | /* ----------------------------------------------------------------- |
||
36 | | Constructor |
||
37 | | ----------------------------------------------------------------- |
||
38 | */ |
||
39 | |||
40 | /** |
||
41 | * Middleware constructor. |
||
42 | * |
||
43 | * @param \Arcanedev\Localization\Contracts\Localization $localization |
||
44 | */ |
||
45 | 10 | public function __construct(Localization $localization) |
|
50 | |||
51 | /* ----------------------------------------------------------------- |
||
52 | | Getters & Setters |
||
53 | | ----------------------------------------------------------------- |
||
54 | */ |
||
55 | /** |
||
56 | * Get the default locale. |
||
57 | * |
||
58 | * @return string |
||
59 | */ |
||
60 | 10 | public function getDefaultLocale() |
|
64 | |||
65 | /** |
||
66 | * Get the current locale. |
||
67 | * |
||
68 | * @return string |
||
69 | */ |
||
70 | 6 | public function getCurrentLocale() |
|
74 | |||
75 | /** |
||
76 | * Return an array of all supported Locales. |
||
77 | * |
||
78 | * @throws UndefinedSupportedLocalesException |
||
79 | * |
||
80 | * @return LocaleCollection |
||
81 | */ |
||
82 | 6 | public function getSupportedLocales() |
|
86 | |||
87 | /** |
||
88 | * Hide the default locale in URL ?? |
||
89 | * |
||
90 | * @return bool |
||
91 | */ |
||
92 | 6 | protected function hideDefaultLocaleInURL() |
|
96 | |||
97 | /* ----------------------------------------------------------------- |
||
98 | | Check Methods |
||
99 | | ----------------------------------------------------------------- |
||
100 | */ |
||
101 | |||
102 | /** |
||
103 | * Check is default locale hidden. |
||
104 | * |
||
105 | * @param string|null $locale |
||
106 | * |
||
107 | * @return bool |
||
108 | */ |
||
109 | 4 | protected function isDefaultLocaleHidden($locale) |
|
113 | |||
114 | /** |
||
115 | * Determine if the request has a URI that should not be localized. |
||
116 | * |
||
117 | * @param \Illuminate\Http\Request $request |
||
118 | * |
||
119 | * @return bool |
||
120 | */ |
||
121 | 10 | protected function shouldIgnore($request) |
|
133 | |||
134 | /* ----------------------------------------------------------------- |
||
135 | | Other Methods |
||
136 | | ----------------------------------------------------------------- |
||
137 | */ |
||
138 | |||
139 | /** |
||
140 | * Get the redirection response. |
||
141 | * |
||
142 | * @param string $locale |
||
143 | * |
||
144 | * @return \Illuminate\Http\RedirectResponse|null |
||
145 | */ |
||
146 | 4 | protected function getLocalizedRedirect($locale) |
|
154 | |||
155 | /** |
||
156 | * Make a redirect response. |
||
157 | * |
||
158 | * @param string $url |
||
159 | * @param int $code |
||
160 | * |
||
161 | * @return \Illuminate\Http\RedirectResponse |
||
162 | */ |
||
163 | 8 | protected function makeRedirectResponse($url, $code = 302) |
|
167 | } |
||
168 |