Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

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

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

jsifalda opened this issue Dec 19, 2012 · 5 comments

Comments

@jsifalda
Copy link
Contributor

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
Copy link
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') );

@trunda
Copy link

trunda commented Jan 22, 2013

Problem is in this method.

@rostenkowski
Copy link
Contributor

probably related issue #880

@jsifalda
Copy link
Contributor Author

Is there any solution or explanation? Please.

@dg
Copy link
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
Projects
None yet
Development

No branches or pull requests

5 participants