Skip to content
This repository
Browse code

API CHANGE Renames Transliterator to SS_Transliterator

The intl extension in PHP 5.4 provides a Transliterator class, which
conflicts with the SilverStripe one. This leads to some really weird
ReflectionExceptions about Transliterator's constructor being
private.
  • Loading branch information...
commit 9bd77652723a77f65f36b70ba543ea3c20dba829 1 parent e3e15e4
Simon Welsh authored June 15, 2012
8  filesystem/FileNameFilter.php
@@ -91,22 +91,22 @@ function getReplacements() {
91 91
 	}
92 92
 		
93 93
 	/**
94  
-	 * @var Transliterator
  94
+	 * @var SS_Transliterator
95 95
 	 */
96 96
 	protected $transliterator;
97 97
 	
98 98
 	/**
99  
-	 * @return Transliterator|NULL
  99
+	 * @return SS_Transliterator|NULL
100 100
 	 */
101 101
 	function getTransliterator() {
102 102
 		if($this->transliterator === null && self::$default_use_transliterator) {
103  
-			$this->transliterator = Transliterator::create();
  103
+			$this->transliterator = SS_Transliterator::create();
104 104
 		} 
105 105
 		return $this->transliterator;
106 106
 	}
107 107
 	
108 108
 	/**
109  
-	 * @param Transliterator|FALSE
  109
+	 * @param SS_Transliterator|FALSE
110 110
 	 */
111 111
 	function setTransliterator($t) {
112 112
 		$this->transliterator = $t;
4  model/Transliterator.php
@@ -6,14 +6,14 @@
6 6
  * Usage:
7 7
  * 
8 8
  * <code>
9  
- * $tr = new Transliterator();
  9
+ * $tr = new SS_Transliterator();
10 10
  * $ascii = $tr->toASCII($unicode);
11 11
  * </code>
12 12
  * 
13 13
  * @package framework
14 14
  * @subpackage model
15 15
  */
16  
-class Transliterator extends Object {
  16
+class SS_Transliterator extends Object {
17 17
 	/**
18 18
 	 * Allow the use of iconv() to perform transliteration.  Set to false to disable.
19 19
 	 * Even if this variable is true, iconv() won't be used if it's not installed.
10  model/URLSegmentFilter.php
@@ -6,7 +6,7 @@
6 6
 
7 7
 /**
8 8
  * Filter certain characters from "URL segments" (also called "slugs"), for nicer (more SEO-friendly) URLs.
9  
- * Uses {@link Transliterator} to convert non-ASCII characters to meaningful ASCII representations.
  9
+ * Uses {@link SS_Transliterator} to convert non-ASCII characters to meaningful ASCII representations.
10 10
  * Use {@link $default_allow_multibyte} to allow a broader range of characters without transliteration.
11 11
  * 
12 12
  * Caution: Should not be used on full URIs with domains or query parameters.
@@ -94,22 +94,22 @@ function getReplacements() {
94 94
 	}
95 95
 		
96 96
 	/**
97  
-	 * @var Transliterator
  97
+	 * @var SS_Transliterator
98 98
 	 */
99 99
 	protected $transliterator;
100 100
 	
101 101
 	/**
102  
-	 * @return Transliterator|NULL
  102
+	 * @return SS_Transliterator|NULL
103 103
 	 */
104 104
 	function getTransliterator() {
105 105
 		if($this->transliterator === null && self::$default_use_transliterator) {
106  
-			$this->transliterator = Transliterator::create();
  106
+			$this->transliterator = SS_Transliterator::create();
107 107
 		} 
108 108
 		return $this->transliterator;
109 109
 	}
110 110
 	
111 111
 	/**
112  
-	 * @param Transliterator|FALSE
  112
+	 * @param SS_Transliterator|FALSE
113 113
 	 */
114 114
 	function setTransliterator($t) {
115 115
 		$this->transliterator = $t;
4  tests/filesystem/FileNameFilterTest.php
@@ -18,7 +18,7 @@ function testFilter() {
18 18
 	function testFilterWithTransliterator() {
19 19
 		$name = 'Brötchen  für allë-mit_Unterstrich!.jpg';
20 20
 		$filter = new FileNameFilter();
21  
-		$filter->setTransliterator(new Transliterator());
  21
+		$filter->setTransliterator(new SS_Transliterator());
22 22
 		$this->assertEquals(
23 23
 			'Broetchen-fuer-alle-mit-Unterstrich.jpg', 
24 24
 			$filter->filter($name)
@@ -39,7 +39,7 @@ function testFilterWithCustomRules() {
39 39
 	function testFilterWithEmptyString() {
40 40
 		$name = 'ö ö ö.jpg';
41 41
 		$filter = new FileNameFilter();
42  
-		$filter->setTransliterator(new Transliterator());
  42
+		$filter->setTransliterator(new SS_Transliterator());
43 43
 		$result = $filter->filter($name);
44 44
 		$this->assertFalse(
45 45
 			empty($result)

0 notes on commit 9bd7765

Please sign in to comment.
Something went wrong with that request. Please try again.