routing to a distinct presenter

gregor_nette
Member | 12
+
0
-

Hi!
I'm trying to get a mapping from /login to get to a presenter somewhere hidden in the app/Presenters directory.

This is the app/Router/RouterFactory.php

<?php
declare(strict_types=1);

namespace App\Router;

use Nette;
use Nette\Application\Routers\RouteList;

final class RouterFactory
{
    use Nette\StaticClass;
    public static function createRouter(): RouteList
    {
        $router = new RouteList();
        $router = new RouteList();
        $router->addRoute('/login', 'Dashboard:Sign:in');
        return $router;
    }
}

This is the presenter I try to reach
app/Presenters/DashboardModule/Presenters/SignPresenter.php

<?php

declare(strict_types=1);

namespace App\DashboardModule\Presenters;

use Nette;
use Nette\Application\UI\Form;
use Nette\Security\User;

final class SignPresenter extends Presenter {
.....
    public function actionIn(): void
    {
         $this->flashMessage('People wont be people, when they hear this song.');
    }
.....

}

This is a part of the configuration config/common.neon

application:
    errorPresenter: Error
    mapping:
        *: App\*Module\Presenters\*Presenter

I get

 Cannot load presenter 'Dashboard:Homepage', class 'App\DashboardModule\Presenters\HomepagePresenter' was not found

What am I missing? Any hints are welcome. Do I have to change the Router/Namespace??

Thanks :-)

petr.pavel
Member | 531
+
0
-

What is the url you requested?

The error mentions HomepagePresenter but it's not listed in your router. You're not telling us something ;-)

gregor_nette
Member | 12
+
0
-

Sheit!!
You are right. I removed parts to get rid off of some distraction, but I went too far…

Here's the RouterFactory without comments

<?php

declare(strict_types=1);

namespace App\Router;

use Nette;
use Nette\Application\Routers\RouteList;

final class RouterFactory
{
    use Nette\StaticClass;
    public static function createRouter(): RouteList
    {
        $router = new RouteList();
        $router->addRoute('/login', 'Dashboard:Sign:in');

        $router->addRoute('/dashboard/<action>[/<val>]', 'Dashboard:update');
        $router->addRoute('<presenter>/<action>[/<val>]', 'Homepage:start');
        return $router;
    }
}
gregor_nette
Member | 12
+
0
-

I finally got it!
It was a problem with not expired cache AND my lack of understanding of presenters…
But it`s getting better.

Thanks