Created
August 20, 2013 20:40
-
-
Save 0x46616c6b/6286987 to your computer and use it in GitHub Desktop.
Use a custom sluggable listener to convert the german "Umlaute" correctly
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Index: app/config/config.yml | |
IDEA additional info: | |
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
<+>UTF-8 | |
=================================================================== | |
--- app/config/config.yml (revision d38cd17) | |
+++ app/config/config.yml (revision 8f4f85a5ccd3e17b6bbe235fed1b5cff44c07d65) | |
@@ -68,6 +68,8 @@ | |
default: | |
timestampable: true | |
sluggable: true | |
+ class: | |
+ sluggable: Systemli\MemorialBundle\Listener\SluggableListener | |
sonata_block: | |
default_contexts: [cms] | |
\ No newline at end of file | |
Index: src/Systemli/MemorialBundle/Listener/SluggableListener.php | |
IDEA additional info: | |
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
<+>UTF-8 | |
=================================================================== | |
--- src/Systemli/MemorialBundle/Listener/SluggableListener.php (revision 8f4f85a5ccd3e17b6bbe235fed1b5cff44c07d65) | |
+++ src/Systemli/MemorialBundle/Listener/SluggableListener.php (revision 8f4f85a5ccd3e17b6bbe235fed1b5cff44c07d65) | |
@@ -0,0 +1,13 @@ | |
+<?php | |
+ | |
+namespace Systemli\MemorialBundle\Listener; | |
+ | |
+use Gedmo\Sluggable\SluggableListener as BaseSluggableListener; | |
+ | |
+class SluggableListener extends BaseSluggableListener | |
+{ | |
+ public function __construct() | |
+ { | |
+ $this->setTransliterator(array('\Systemli\MemorialBundle\Util\Transliterator', 'transliterate')); | |
+ } | |
+} | |
\ No newline at end of file | |
Index: src/Systemli/MemorialBundle/Util/Transliterator.php | |
IDEA additional info: | |
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
<+>UTF-8 | |
=================================================================== | |
--- src/Systemli/MemorialBundle/Util/Transliterator.php (revision 8f4f85a5ccd3e17b6bbe235fed1b5cff44c07d65) | |
+++ src/Systemli/MemorialBundle/Util/Transliterator.php (revision 8f4f85a5ccd3e17b6bbe235fed1b5cff44c07d65) | |
@@ -0,0 +1,16 @@ | |
+<?php | |
+ | |
+namespace Systemli\MemorialBundle\Util; | |
+ | |
+use Gedmo\Sluggable\Util\Urlizer; | |
+ | |
+class Transliterator | |
+{ | |
+ public static function transliterate($text, $separator = '-') | |
+ { | |
+ $text = Urlizer::unaccent($text); | |
+ return Urlizer::urlize($text, $separator); | |
+ } | |
+ | |
+ | |
+} | |
\ No newline at end of file |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment