Skip to content

Commit 2d1e6b9

Browse files
committed
PresenterFactory: removed $caseSensitive, presenter names are always case sensitive (BC break)
1 parent 260ac01 commit 2d1e6b9

File tree

3 files changed

+2
-91
lines changed

3 files changed

+2
-91
lines changed

src/Application/Application.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@ public function createInitialRequest()
123123
try {
124124
$name = $request->getPresenterName();
125125
$this->presenterFactory->getPresenterClass($name);
126-
$request->setPresenterName($name);
127126
} catch (InvalidPresenterException $e) {
128127
throw new BadRequestException($e->getMessage(), 0, $e);
129128
}

src/Application/PresenterFactory.php

Lines changed: 2 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@
1717
*/
1818
class PresenterFactory extends Nette\Object implements IPresenterFactory
1919
{
20-
/** @var bool */
21-
public $caseSensitive = FALSE;
22-
2320
/** @var array[] of module => splited mask */
2421
private $mapping = array(
2522
'*' => array('', '*Module\\', '*Presenter'),
@@ -74,8 +71,7 @@ public function createPresenter($name)
7471
public function getPresenterClass(& $name)
7572
{
7673
if (isset($this->cache[$name])) {
77-
list($class, $name) = $this->cache[$name];
78-
return $class;
74+
return $this->cache[$name];
7975
}
8076

8177
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)
9692
throw new InvalidPresenterException("Cannot load presenter '$name', class '$class' is abstract.");
9793
}
9894

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;
11396
}
11497

11598

@@ -148,22 +131,4 @@ public function formatPresenterClass($presenter)
148131
return $mapping[0];
149132
}
150133

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-
169134
}

tests/Application/PresenterFactory.unformatPresenterClass.phpt

Lines changed: 0 additions & 53 deletions
This file was deleted.

0 commit comments

Comments
 (0)