Skip to content

Commit 57bd587

Browse files
committed
PresenterFactory: default mapping is App\UI\*\**Presenter (BC break)
1 parent dbe6421 commit 57bd587

File tree

4 files changed

+16
-13
lines changed

4 files changed

+16
-13
lines changed

src/Application/PresenterFactory.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class PresenterFactory implements IPresenterFactory
1919
{
2020
/** @var array[] of module => splited mask */
2121
private array $mapping = [
22-
'*' => ['', '*Module\\', '*Presenter'],
22+
'*' => ['App\\UI\\', '*\\', '**Presenter'],
2323
'Nette' => ['NetteModule\\', '*\\', '*Presenter'],
2424
];
2525

tests/Application/PresenterFactory.formatPresenterClass.phpt

+9-9
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ test('defined module', function () {
2121
'Foo3' => 'My\App\*Mod\*Presenter',
2222
]);
2323

24-
Assert::same('FooPresenter', $factory->formatPresenterClass('Foo'));
25-
Assert::same('FooModule\BarPresenter', $factory->formatPresenterClass('Foo:Bar'));
26-
Assert::same('FooModule\BarModule\BazPresenter', $factory->formatPresenterClass('Foo:Bar:Baz'));
24+
Assert::same('App\UI\Foo\FooPresenter', $factory->formatPresenterClass('Foo'));
25+
Assert::same('App\UI\Foo\Bar\BarPresenter', $factory->formatPresenterClass('Foo:Bar'));
26+
Assert::same('App\UI\Foo\Bar\Baz\BazPresenter', $factory->formatPresenterClass('Foo:Bar:Baz'));
2727

28-
Assert::same('Foo2Presenter', $factory->formatPresenterClass('Foo2'));
28+
Assert::same('App\UI\Foo2\Foo2Presenter', $factory->formatPresenterClass('Foo2'));
2929
Assert::same('App2\BarPresenter', $factory->formatPresenterClass('Foo2:Bar'));
3030
Assert::same('App2\Bar\BazPresenter', $factory->formatPresenterClass('Foo2:Bar:Baz'));
3131

@@ -44,7 +44,7 @@ test('auto module', function () {
4444
'Foo3' => 'My\App\*Presenter',
4545
]);
4646

47-
Assert::same('Foo2Presenter', $factory->formatPresenterClass('Foo2'));
47+
Assert::same('App\UI\Foo2\Foo2Presenter', $factory->formatPresenterClass('Foo2'));
4848
Assert::same('App2\BarPresenter', $factory->formatPresenterClass('Foo2:Bar'));
4949
Assert::same('App2\BarModule\BazPresenter', $factory->formatPresenterClass('Foo2:Bar:Baz'));
5050

@@ -61,11 +61,11 @@ test('location ** & defined module', function () {
6161
'Foo3' => 'My\App\*Mod\**Presenter',
6262
]);
6363

64-
Assert::same('FooPresenter', $factory->formatPresenterClass('Foo'));
65-
Assert::same('FooModule\BarPresenter', $factory->formatPresenterClass('Foo:Bar'));
66-
Assert::same('FooModule\BarModule\BazPresenter', $factory->formatPresenterClass('Foo:Bar:Baz'));
64+
Assert::same('App\UI\Foo\FooPresenter', $factory->formatPresenterClass('Foo'));
65+
Assert::same('App\UI\Foo\Bar\BarPresenter', $factory->formatPresenterClass('Foo:Bar'));
66+
Assert::same('App\UI\Foo\Bar\Baz\BazPresenter', $factory->formatPresenterClass('Foo:Bar:Baz'));
6767

68-
Assert::same('Foo2Presenter', $factory->formatPresenterClass('Foo2'));
68+
Assert::same('App\UI\Foo2\Foo2Presenter', $factory->formatPresenterClass('Foo2'));
6969
Assert::same('App2\Bar\BarPresenter', $factory->formatPresenterClass('Foo2:Bar'));
7070
Assert::same('App2\Bar\Baz\BazPresenter', $factory->formatPresenterClass('Foo2:Bar:Baz'));
7171

tests/Routers/LinkGenerator.phpt

+5-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66

77
declare(strict_types=1);
88

9-
namespace {
9+
namespace App\UI\Homepage {
10+
11+
use Nette;
1012

1113
require __DIR__ . '/../bootstrap.php';
1214

@@ -24,7 +26,7 @@ namespace {
2426

2527
}
2628

27-
namespace ModuleModule {
29+
namespace App\UI\Module\My {
2830

2931
use Nette;
3032

@@ -77,7 +79,7 @@ namespace {
7779
Assert::exception(function () use ($pf) {
7880
$generator = new LinkGenerator(new Routers\Route('/', 'Homepage:'), new Http\UrlScript('http://nette.org/en/'), $pf);
7981
$generator->link('Homepage:missing', [10]);
80-
}, Nette\Application\UI\InvalidLinkException::class, "Unable to pass parameters to action 'Homepage:missing', missing corresponding method HomepagePresenter::renderMissing().");
82+
}, Nette\Application\UI\InvalidLinkException::class, "Unable to pass parameters to action 'Homepage:missing', missing corresponding method App\\UI\\Homepage\\HomepagePresenter::renderMissing().");
8183

8284

8385
test('', function () {

tests/Routers/link-aliases.phpt

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class TestPresenter extends Application\UI\Presenter
2020

2121

2222
$factory = new PresenterFactory;
23+
$factory->setMapping(['*' => '*Presenter']);
2324
$factory->setAliases([
2425
'a' => 'Test:a',
2526
'b' => 'Test:b',

0 commit comments

Comments
 (0)