|
@@ -0,0 +1,49 @@
|
|
1
|
+<?php
|
|
2
|
+
|
|
3
|
+/*
|
|
4
|
+ * This file is part of the FOSUserBundle package.
|
|
5
|
+ *
|
|
6
|
+ * (c) FriendsOfSymfony <http://friendsofsymfony.github.com/>
|
|
7
|
+ *
|
|
8
|
+ * For the full copyright and license information, please view the LICENSE
|
|
9
|
+ * file that was distributed with this source code.
|
|
10
|
+ */
|
|
11
|
+
|
|
12
|
+namespace Muzich\CoreBundle\Util;
|
|
13
|
+use FOS\UserBundle\Util\CanonicalizerInterface;
|
|
14
|
+
|
|
15
|
+class StrictCanonicalizer implements CanonicalizerInterface
|
|
16
|
+{
|
|
17
|
+ public function remove_accent($texte)
|
|
18
|
+ {
|
|
19
|
+ $texte = mb_strtolower($texte, 'UTF-8');
|
|
20
|
+ $texte = str_replace(
|
|
21
|
+ array(
|
|
22
|
+ 'à', 'â', 'ä', 'á', 'ã', 'å',
|
|
23
|
+ 'î', 'ï', 'ì', 'í',
|
|
24
|
+ 'ô', 'ö', 'ò', 'ó', 'õ', 'ø',
|
|
25
|
+ 'ù', 'û', 'ü', 'ú',
|
|
26
|
+ 'é', 'è', 'ê', 'ë',
|
|
27
|
+ 'ç', 'ÿ', 'ñ',
|
|
28
|
+ ),
|
|
29
|
+ array(
|
|
30
|
+ 'a', 'a', 'a', 'a', 'a', 'a',
|
|
31
|
+ 'i', 'i', 'i', 'i',
|
|
32
|
+ 'o', 'o', 'o', 'o', 'o', 'o',
|
|
33
|
+ 'u', 'u', 'u', 'u',
|
|
34
|
+ 'e', 'e', 'e', 'e',
|
|
35
|
+ 'c', 'y', 'n',
|
|
36
|
+ ),
|
|
37
|
+ $texte
|
|
38
|
+ );
|
|
39
|
+
|
|
40
|
+ return $texte;
|
|
41
|
+ }
|
|
42
|
+
|
|
43
|
+ public function canonicalize($string)
|
|
44
|
+ {
|
|
45
|
+ $string = mb_convert_case($string, MB_CASE_LOWER, mb_detect_encoding($string));
|
|
46
|
+ // On retire les accents occidentaux.
|
|
47
|
+ return $this->remove_accent($string);
|
|
48
|
+ }
|
|
49
|
+}
|