1 | <?php namespace Arcanedev\Localization\Middleware; |
||
15 | abstract class Middleware extends BaseMiddleware |
||
|
|||
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 | 15 | public function __construct(Localization $localization) |
|
51 | |||
52 | /* ----------------------------------------------------------------- |
||
53 | | Getters & Setters |
||
54 | | ----------------------------------------------------------------- |
||
55 | */ |
||
56 | /** |
||
57 | * Get the default locale. |
||
58 | * |
||
59 | * @return string |
||
60 | */ |
||
61 | 15 | public function getDefaultLocale() |
|
65 | |||
66 | /** |
||
67 | * Get the current locale. |
||
68 | * |
||
69 | * @return string |
||
70 | */ |
||
71 | 9 | public function getCurrentLocale() |
|
75 | |||
76 | /** |
||
77 | * Return an array of all supported Locales. |
||
78 | * |
||
79 | * @throws UndefinedSupportedLocalesException |
||
80 | * |
||
81 | * @return LocaleCollection |
||
82 | */ |
||
83 | 9 | public function getSupportedLocales() |
|
87 | |||
88 | /** |
||
89 | * Hide the default locale in URL ?? |
||
90 | * |
||
91 | * @return bool |
||
92 | */ |
||
93 | 9 | 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 | 6 | 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 | 15 | protected function shouldIgnore($request) |
|
123 | { |
||
124 | 15 | foreach ($this->except as $except) { |
|
125 | if ($except !== '/') |
||
126 | $except = trim($except, '/'); |
||
127 | |||
128 | if ($request->is($except)) |
||
129 | return true; |
||
130 | } |
||
131 | |||
132 | 15 | return false; |
|
133 | } |
||
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 | 6 | protected function getLocalizedRedirect($locale) |
|
155 | |||
156 | /** |
||
157 | * Make a redirect response. |
||
158 | * |
||
159 | * @param string $url |
||
160 | * @param int $code |
||
161 | * |
||
162 | * @return \Illuminate\Http\RedirectResponse |
||
163 | */ |
||
164 | 12 | protected function makeRedirectResponse($url, $code = 302) |
|
168 | } |
||
169 |
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.