1 | <?php namespace Arcanedev\Localization\Middleware; |
||
15 | abstract class Middleware extends BaseMiddleware |
||
16 | { |
||
17 | /* ----------------------------------------------------------------- |
||
18 | | Properties |
||
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 | * Middleware constructor. |
||
41 | * |
||
42 | * @param \Arcanedev\Localization\Contracts\Localization $localization |
||
43 | */ |
||
44 | 15 | public function __construct(Localization $localization) |
|
48 | |||
49 | /* ----------------------------------------------------------------- |
||
50 | | Getters & Setters |
||
51 | | ----------------------------------------------------------------- |
||
52 | */ |
||
53 | /** |
||
54 | * Get the default locale. |
||
55 | * |
||
56 | * @return string |
||
57 | */ |
||
58 | 15 | public function getDefaultLocale() |
|
62 | |||
63 | /** |
||
64 | * Get the current locale. |
||
65 | * |
||
66 | * @return string |
||
67 | */ |
||
68 | 9 | public function getCurrentLocale() |
|
72 | |||
73 | /** |
||
74 | * Return an array of all supported Locales. |
||
75 | * |
||
76 | * @throws UndefinedSupportedLocalesException |
||
77 | * |
||
78 | * @return LocaleCollection |
||
79 | */ |
||
80 | 9 | public function getSupportedLocales() |
|
84 | |||
85 | /** |
||
86 | * Hide the default locale in URL ?? |
||
87 | * |
||
88 | * @return bool |
||
89 | */ |
||
90 | 9 | protected function hideDefaultLocaleInURL() |
|
94 | |||
95 | /* ----------------------------------------------------------------- |
||
96 | | Check Methods |
||
97 | | ----------------------------------------------------------------- |
||
98 | */ |
||
99 | /** |
||
100 | * Check is default locale hidden. |
||
101 | * |
||
102 | * @param string|null $locale |
||
103 | * |
||
104 | * @return bool |
||
105 | */ |
||
106 | 6 | protected function isDefaultLocaleHidden($locale) |
|
110 | |||
111 | /** |
||
112 | * Determine if the request has a URI that should not be localized. |
||
113 | * |
||
114 | * @param \Illuminate\Http\Request $request |
||
115 | * |
||
116 | * @return bool |
||
117 | */ |
||
118 | 15 | protected function shouldIgnore($request) |
|
130 | |||
131 | /* ----------------------------------------------------------------- |
||
132 | | Other Methods |
||
133 | | ----------------------------------------------------------------- |
||
134 | */ |
||
135 | /** |
||
136 | * Get the redirection response. |
||
137 | * |
||
138 | * @param string $locale |
||
139 | * |
||
140 | * @return \Illuminate\Http\RedirectResponse|null |
||
141 | */ |
||
142 | 6 | protected function getLocalizedRedirect($locale) |
|
150 | |||
151 | /** |
||
152 | * Make a redirect response. |
||
153 | * |
||
154 | * @param string $url |
||
155 | * @param int $code |
||
156 | * |
||
157 | * @return \Illuminate\Http\RedirectResponse |
||
158 | */ |
||
159 | 12 | protected function makeRedirectResponse($url, $code = 302) |
|
163 | } |
||
164 |