nette 2.0 to 3.1 and link method

alnux
Member | 139
+
0
-

hi,
i have a question in the past nette 2.0 this was worked

class ........
function x (Nette\Application\Application $application) {

	return $application->presenter->link('this', array($this->presenterLanguageParam => $switchLang));

	}
}

could you help me with this on nette 3.1 becouse link() method not works on

thanks

mystik
Member | 291
+
0
-

What exactly is the problem? What error you get?

alnux
Member | 139
+
-2
-

hi,
the problem is migrating from nette 2.0 to 3.1 as i show in the example above with link() method how can i use it on 3.1 to Generates URL to presenter, action or signal becouse on the way as is on 2.0 does not work

mystik
Member | 291
+
+2
-

Above method should still work I think. Maybe just replace magic property access with direct getPresenter().

Thats way I asked how exactly it fails.

But accessing presenter from global state of Application is not very clean and might fail if used before current presenter id determined in reguest dispatching flow.

Where is this method located? Why cannot you pass presenter from caller instead of Application? I would need a bit more context for better advice.

Unless you need to access currently dispatched presenter (to be able to use this) recommended way would be to use LinkGenerator service and pass exact presenter.