Skip to content

Commit 3463b9a

Browse files
committed
PresenterFactory: default mapping is App\Presentation\*\**Presenter (BC break)
1 parent e21b3eb commit 3463b9a

File tree

4 files changed

+16
-13
lines changed

4 files changed

+16
-13
lines changed

src/Application/PresenterFactory.php

Lines changed: 1 addition & 1 deletion
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\Presentation\\', '*\\', '**Presenter'],
2323
'Nette' => ['NetteModule\\', '*\\', '*Presenter'],
2424
];
2525

tests/Application/PresenterFactory.formatPresenterClass.phpt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ test('complex mapping with multiple wildcards', 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\Presentation\Foo\FooPresenter', $factory->formatPresenterClass('Foo'));
25+
Assert::same('App\Presentation\Foo\Bar\BarPresenter', $factory->formatPresenterClass('Foo:Bar'));
26+
Assert::same('App\Presentation\Foo\Bar\Baz\BazPresenter', $factory->formatPresenterClass('Foo:Bar:Baz'));
2727

28-
Assert::same('Foo2Presenter', $factory->formatPresenterClass('Foo2'));
28+
Assert::same('App\Presentation\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('simple wildcard mapping', function () {
4444
'Foo3' => 'My\App\*Presenter',
4545
]);
4646

47-
Assert::same('Foo2Presenter', $factory->formatPresenterClass('Foo2'));
47+
Assert::same('App\Presentation\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('multi-segment wildcard expansion', 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\Presentation\Foo\FooPresenter', $factory->formatPresenterClass('Foo'));
65+
Assert::same('App\Presentation\Foo\Bar\BarPresenter', $factory->formatPresenterClass('Foo:Bar'));
66+
Assert::same('App\Presentation\Foo\Bar\Baz\BazPresenter', $factory->formatPresenterClass('Foo:Bar:Baz'));
6767

68-
Assert::same('Foo2Presenter', $factory->formatPresenterClass('Foo2'));
68+
Assert::same('App\Presentation\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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66

77
declare(strict_types=1);
88

9-
namespace {
9+
namespace App\Presentation\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\Presentation\Module\My {
2830

2931
use Nette;
3032

@@ -77,7 +79,7 @@ namespace {
7779
testException('invalid action parameter propagation', 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('URL generation without PresenterFactory', function () {

tests/Routers/link-aliases.phpt

Lines changed: 1 addition & 0 deletions
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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy