How to obtain current presenter in IBarPanel implementation
- dakur
- Member | 493
Hi, I need to make a decision about whether render tab/panel in Tracy bar or not based on what is the current presenter. But I do not know how to obtain current presenter in there.
I've tried to let DI inject IPresenter
,
PresenterFactory
and Application
– none of them
worked, loading failed with 0 parameters given, 1 expected
. Maybe
I have to make an extension to be able to pass something there? Seems like to
me when I looked into Nette's RoutingPanel
. But what actually
should I need? Application
? IPresenter
implementation? I don't get it.
Can you please point me to the right way how to do it? Thank you.
final class CampaignLinksPanel implements IBarPanel
{
public function __construct(???)
{}
public function getTab(): string
{
if ( ! ($this->presenter instanceof SomeClass)) {
return '';
}
return '.......';
}
public function getPanel(): string
{
if ( ! ($this->presenter instanceof SomeClass)) {
return '';
}
return '.......';
}
}
- Marek Bartoš
- Nette Blogger | 1261
That's strange as namespace is Nette\Application and package name is nette/application
Extension is registered with name application
and every service
is prefixed by name of extension ($this->prefix('application')
→ 'application.aplication'
). It prevents collisions and
potentially allows register same extension multiple times.
https://github.com/…igurator.php#L32
Last edited by Mabar (2020-08-28 15:54)