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