Bug in generating name of presenters, if mapping is changed #909

Closed
jsifalda opened this Issue Dec 19, 2012 · 5 comments

Comments

Projects
None yet
5 participants
@jsifalda
Contributor

jsifalda commented Dec 19, 2012

I would like to have got presenters in common namespace e.g. Flame\CMS\FrontModule\Presenters.
Ok, that is not a problem. Now I must change mapping in config:

 application:
        mapping:
            *: Flame\CMS\*Module\Presenters\*Presenter

But I get error: Page not found. Missing template '…/FrontModule/templates/FrontModule\Presenters\Homepage/default.latte'.

Is there bug in generating name of namespace?

@Majkl578

This comment has been minimized.

Show comment
Hide comment
@Majkl578

Majkl578 Dec 19, 2012

Contributor

There is a problem with "Presenters" part. Some tests:

diff --git a/tests/Nette/Application/PresenterFactory.formatPresenterClass.phpt b/tests/Nette/Application/PresenterFactory.formatPresenterClass.phpt
index 0ca5bd0..ddee0c2 100644
--- a/tests/Nette/Application/PresenterFactory.formatPresenterClass.phpt
+++ b/tests/Nette/Application/PresenterFactory.formatPresenterClass.phpt
@@ -22,6 +22,7 @@ $factory = new PresenterFactory(NULL, $container);

 $factory->mapping['Foo2'] = 'App2\*\*Presenter';
 $factory->mapping['Foo3'] = 'My\App\*Mod\*Presenter';
+$factory->mapping['Foo4'] = 'My\App\*Mod\Presenters\*Presenter';

 Assert::same( 'FooPresenter', $factory->formatPresenterClass('Foo') );
 Assert::same( 'FooModule\BarPresenter', $factory->formatPresenterClass('Foo:Bar') );
@@ -34,4 +35,7 @@ Assert::same( 'App2\Bar\BazPresenter', $factory->formatPresenterClass('Foo2:Bar:
 Assert::same( 'My\App\BarPresenter', $factory->formatPresenterClass('Foo3:Bar') );
 Assert::same( 'My\App\BarMod\BazPresenter', $factory->formatPresenterClass('Foo3:Bar:Baz') );

+Assert::same( 'My\App\Presenters\BarPresenter', $factory->formatPresenterClass('Foo4:Bar') );
+Assert::same( 'My\App\BarMod\Presenters\BazPresenter', $factory->formatPresenterClass('Foo4:Bar:Baz') );
+
 Assert::same( 'NetteModule\FooPresenter', $factory->formatPresenterClass('Nette:Foo') );
diff --git a/tests/Nette/Application/PresenterFactory.formatPresenterFile.phpt b/tests/Nette/Application/PresenterFactory.formatPresenterFile.phpt
index 8757a2c..0841810 100644
--- a/tests/Nette/Application/PresenterFactory.formatPresenterFile.phpt
+++ b/tests/Nette/Application/PresenterFactory.formatPresenterFile.phpt
@@ -21,6 +21,7 @@ $container = id(new Nette\Config\Configurator)->setTempDirectory(TEMP_DIR)->crea
 $factory = new PresenterFactory('base', $container);

 $factory->mapping['Foo2'] = 'App2\*\*Presenter';
+$factory->mapping['Foo3'] = 'App2\*\Presenters\*Presenter';

 Assert::same( 'base/presenters/FooPresenter.php', $factory->formatPresenterFile('Foo') );
 Assert::same( 'base/FooModule/presenters/BarPresenter.php', $factory->formatPresenterFile('Foo:Bar') );
@@ -29,3 +30,7 @@ Assert::same( 'base/FooModule/BarModule/presenters/BazPresenter.php', $factory->
 Assert::same( 'base/presenters/Foo2Presenter.php', $factory->formatPresenterFile('Foo2') );
 Assert::same( 'base/Foo2Module/presenters/BarPresenter.php', $factory->formatPresenterFile('Foo2:Bar') );
 Assert::same( 'base/Foo2Module/BarModule/presenters/BazPresenter.php', $factory->formatPresenterFile('Foo2:Bar:Baz') );
+
+Assert::same( 'base/presenters/Foo3Presenter.php', $factory->formatPresenterFile('Foo3') );
+Assert::same( 'base/Foo3Module/presenters/BarPresenter.php', $factory->formatPresenterFile('Foo3:Bar') );
+Assert::same( 'base/Foo3Module/BarModule/presenters/BazPresenter.php', $factory->formatPresenterFile('Foo3:Bar:Baz') );
diff --git a/tests/Nette/Application/PresenterFactory.unformatPresenterClass.phpt b/tests/Nette/Application/PresenterFactory.unformatPresenterClass.phpt
index 03a844d..b020aae 100644
--- a/tests/Nette/Application/PresenterFactory.unformatPresenterClass.phpt
+++ b/tests/Nette/Application/PresenterFactory.unformatPresenterClass.phpt
@@ -22,6 +22,8 @@ $factory = new PresenterFactory(NULL, $container);

 $factory->mapping['Foo2'] = 'App2\*\*Presenter';
 $factory->mapping['Foo3'] = 'My\App\*Mod\*Presenter';
+$factory->mapping['Foo4'] = 'My\App\*Mod\Presenters\*Presenter';
+//$factory->mapping['Sub1:Sub2'] = 'App\*Mod\*Presenter';

 Assert::same( 'Foo', $factory->unformatPresenterClass('FooPresenter') );
 Assert::same( 'Foo:Bar', $factory->unformatPresenterClass('FooModule\BarPresenter') );
@@ -34,5 +36,8 @@ Assert::same( 'Foo2:Bar:Baz', $factory->unformatPresenterClass('App2\Bar\BazPres
 Assert::same( 'Foo3:Bar', $factory->unformatPresenterClass('My\App\BarPresenter') );
 Assert::same( 'Foo3:Bar:Baz', $factory->unformatPresenterClass('My\App\BarMod\BazPresenter') );

+Assert::same( 'Foo4:Bar', $factory->unformatPresenterClass('My\App\Presenters\BarPresenter') );
+Assert::same( 'Foo4:Bar:Baz', $factory->unformatPresenterClass('My\App\BarMod\Presenters\BazPresenter') );
+
 Assert::same( NULL, $factory->unformatPresenterClass('Foo') );
 Assert::same( NULL, $factory->unformatPresenterClass('FooMod\BarPresenter') );
Contributor

Majkl578 commented Dec 19, 2012

There is a problem with "Presenters" part. Some tests:

diff --git a/tests/Nette/Application/PresenterFactory.formatPresenterClass.phpt b/tests/Nette/Application/PresenterFactory.formatPresenterClass.phpt
index 0ca5bd0..ddee0c2 100644
--- a/tests/Nette/Application/PresenterFactory.formatPresenterClass.phpt
+++ b/tests/Nette/Application/PresenterFactory.formatPresenterClass.phpt
@@ -22,6 +22,7 @@ $factory = new PresenterFactory(NULL, $container);

 $factory->mapping['Foo2'] = 'App2\*\*Presenter';
 $factory->mapping['Foo3'] = 'My\App\*Mod\*Presenter';
+$factory->mapping['Foo4'] = 'My\App\*Mod\Presenters\*Presenter';

 Assert::same( 'FooPresenter', $factory->formatPresenterClass('Foo') );
 Assert::same( 'FooModule\BarPresenter', $factory->formatPresenterClass('Foo:Bar') );
@@ -34,4 +35,7 @@ Assert::same( 'App2\Bar\BazPresenter', $factory->formatPresenterClass('Foo2:Bar:
 Assert::same( 'My\App\BarPresenter', $factory->formatPresenterClass('Foo3:Bar') );
 Assert::same( 'My\App\BarMod\BazPresenter', $factory->formatPresenterClass('Foo3:Bar:Baz') );

+Assert::same( 'My\App\Presenters\BarPresenter', $factory->formatPresenterClass('Foo4:Bar') );
+Assert::same( 'My\App\BarMod\Presenters\BazPresenter', $factory->formatPresenterClass('Foo4:Bar:Baz') );
+
 Assert::same( 'NetteModule\FooPresenter', $factory->formatPresenterClass('Nette:Foo') );
diff --git a/tests/Nette/Application/PresenterFactory.formatPresenterFile.phpt b/tests/Nette/Application/PresenterFactory.formatPresenterFile.phpt
index 8757a2c..0841810 100644
--- a/tests/Nette/Application/PresenterFactory.formatPresenterFile.phpt
+++ b/tests/Nette/Application/PresenterFactory.formatPresenterFile.phpt
@@ -21,6 +21,7 @@ $container = id(new Nette\Config\Configurator)->setTempDirectory(TEMP_DIR)->crea
 $factory = new PresenterFactory('base', $container);

 $factory->mapping['Foo2'] = 'App2\*\*Presenter';
+$factory->mapping['Foo3'] = 'App2\*\Presenters\*Presenter';

 Assert::same( 'base/presenters/FooPresenter.php', $factory->formatPresenterFile('Foo') );
 Assert::same( 'base/FooModule/presenters/BarPresenter.php', $factory->formatPresenterFile('Foo:Bar') );
@@ -29,3 +30,7 @@ Assert::same( 'base/FooModule/BarModule/presenters/BazPresenter.php', $factory->
 Assert::same( 'base/presenters/Foo2Presenter.php', $factory->formatPresenterFile('Foo2') );
 Assert::same( 'base/Foo2Module/presenters/BarPresenter.php', $factory->formatPresenterFile('Foo2:Bar') );
 Assert::same( 'base/Foo2Module/BarModule/presenters/BazPresenter.php', $factory->formatPresenterFile('Foo2:Bar:Baz') );
+
+Assert::same( 'base/presenters/Foo3Presenter.php', $factory->formatPresenterFile('Foo3') );
+Assert::same( 'base/Foo3Module/presenters/BarPresenter.php', $factory->formatPresenterFile('Foo3:Bar') );
+Assert::same( 'base/Foo3Module/BarModule/presenters/BazPresenter.php', $factory->formatPresenterFile('Foo3:Bar:Baz') );
diff --git a/tests/Nette/Application/PresenterFactory.unformatPresenterClass.phpt b/tests/Nette/Application/PresenterFactory.unformatPresenterClass.phpt
index 03a844d..b020aae 100644
--- a/tests/Nette/Application/PresenterFactory.unformatPresenterClass.phpt
+++ b/tests/Nette/Application/PresenterFactory.unformatPresenterClass.phpt
@@ -22,6 +22,8 @@ $factory = new PresenterFactory(NULL, $container);

 $factory->mapping['Foo2'] = 'App2\*\*Presenter';
 $factory->mapping['Foo3'] = 'My\App\*Mod\*Presenter';
+$factory->mapping['Foo4'] = 'My\App\*Mod\Presenters\*Presenter';
+//$factory->mapping['Sub1:Sub2'] = 'App\*Mod\*Presenter';

 Assert::same( 'Foo', $factory->unformatPresenterClass('FooPresenter') );
 Assert::same( 'Foo:Bar', $factory->unformatPresenterClass('FooModule\BarPresenter') );
@@ -34,5 +36,8 @@ Assert::same( 'Foo2:Bar:Baz', $factory->unformatPresenterClass('App2\Bar\BazPres
 Assert::same( 'Foo3:Bar', $factory->unformatPresenterClass('My\App\BarPresenter') );
 Assert::same( 'Foo3:Bar:Baz', $factory->unformatPresenterClass('My\App\BarMod\BazPresenter') );

+Assert::same( 'Foo4:Bar', $factory->unformatPresenterClass('My\App\Presenters\BarPresenter') );
+Assert::same( 'Foo4:Bar:Baz', $factory->unformatPresenterClass('My\App\BarMod\Presenters\BazPresenter') );
+
 Assert::same( NULL, $factory->unformatPresenterClass('Foo') );
 Assert::same( NULL, $factory->unformatPresenterClass('FooMod\BarPresenter') );
@trunda

This comment has been minimized.

Show comment
Hide comment

trunda commented Jan 22, 2013

Problem is in this method.

@rostenkowski

This comment has been minimized.

Show comment
Hide comment
@rostenkowski

rostenkowski Jan 23, 2013

Contributor

probably related issue #880

Contributor

rostenkowski commented Jan 23, 2013

probably related issue #880

@jsifalda

This comment has been minimized.

Show comment
Hide comment
@jsifalda

jsifalda Mar 30, 2013

Contributor

Is there any solution or explanation? Please.

Contributor

jsifalda commented Mar 30, 2013

Is there any solution or explanation? Please.

@dg

This comment has been minimized.

Show comment
Hide comment
@dg

dg Mar 31, 2013

Member

There is nearly the same issue #880.

Member

dg commented Mar 31, 2013

There is nearly the same issue #880.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment