17
17
*/
18
18
class PresenterFactory extends Nette \Object implements IPresenterFactory
19
19
{
20
- /** @var bool */
21
- public $ caseSensitive = FALSE ;
22
-
23
20
/** @var array[] of module => splited mask */
24
21
private $ mapping = array (
25
22
'* ' => array ('' , '*Module \\' , '*Presenter ' ),
@@ -74,8 +71,7 @@ public function createPresenter($name)
74
71
public function getPresenterClass (& $ name )
75
72
{
76
73
if (isset ($ this ->cache [$ name ])) {
77
- list ($ class , $ name ) = $ this ->cache [$ name ];
78
- return $ class ;
74
+ return $ this ->cache [$ name ];
79
75
}
80
76
81
77
if (!is_string ($ name ) || !Nette \Utils \Strings::match ($ name , '#^[a-zA-Z\x7f-\xff][a-zA-Z0-9\x7f-\xff:]*\z# ' )) {
@@ -96,20 +92,7 @@ public function getPresenterClass(& $name)
96
92
throw new InvalidPresenterException ("Cannot load presenter ' $ name', class ' $ class' is abstract. " );
97
93
}
98
94
99
- // canonicalize presenter name
100
- $ realName = $ this ->unformatPresenterClass ($ class );
101
- if ($ name !== $ realName ) {
102
- if ($ this ->caseSensitive ) {
103
- throw new InvalidPresenterException ("Cannot load presenter ' $ name', case mismatch. Real name is ' $ realName'. " );
104
- } else {
105
- $ this ->cache [$ name ] = array ($ class , $ realName );
106
- $ name = $ realName ;
107
- }
108
- } else {
109
- $ this ->cache [$ name ] = array ($ class , $ realName );
110
- }
111
-
112
- return $ class ;
95
+ return $ this ->cache [$ name ] = $ class ;
113
96
}
114
97
115
98
@@ -148,22 +131,4 @@ public function formatPresenterClass($presenter)
148
131
return $ mapping [0 ];
149
132
}
150
133
151
-
152
- /**
153
- * Formats presenter name from class name.
154
- * @param string
155
- * @return string
156
- * @internal
157
- */
158
- public function unformatPresenterClass ($ class )
159
- {
160
- foreach ($ this ->mapping as $ module => $ mapping ) {
161
- $ mapping = str_replace (array ('\\' , '* ' ), array ('\\\\' , '(\w+) ' ), $ mapping );
162
- if (preg_match ("#^ \\\\? $ mapping [0 ]((?: $ mapping [1 ])*) $ mapping [2 ]\\z#i " , $ class , $ matches )) {
163
- return ($ module === '* ' ? '' : $ module . ': ' )
164
- . preg_replace ("# $ mapping [1 ]#iA " , '$1: ' , $ matches [1 ]) . $ matches [3 ];
165
- }
166
- }
167
- }
168
-
169
134
}
0 commit comments