Tracy IBarPanel not shown when registered via extension

old.gandalf
Member | 17
+
0
-

Good morning,

I'm experiencing a strange problem (it is possible that it is only an error in my configuration, but I can't figure it out): I've been using the https://github.com/…s/FileMailer tracy extension for quite a while. In it's recent upgrade, a possibility to set it up via an extension has been offered.
The config of the extension is pretty simple:

extensions:
    mailer: RM\MailPanel\DI\MailPanelExtension

mailer:
    hideEmpty: no

However, the panel does not appear in Tracy.
And now the strange part: if the FileMailer class (not the MailPanel one!) is injected into a presenter, the panel appears at the very end of the Tracy Bar, as if it was “registered” as the last one.

If I insert following code into the MailPanelExtension class,

<?php

    public function afterCompile(\Nette\PhpGenerator\ClassType $class) {
        $init = $class->methods['initialize'];
        $init->addBody('$this->getByType("RM\FileMailer");');
    }

?>

the panel appears normally.
This makes me think that perhaps some kind of lazy loading is used, so that the class instance is not created if not needed. But that is a bit against the purpose of extensions like this one, isn't it? I think, once I register it in config, I should not have to worry about it any more.

Many thanks for your help, I assume it will help me understand more of DI principles.

Milo
Nette Core | 1149
+
0
-

I'm using this panel too and the same config as yours works fine. Try the last dev version.

Comments

old.gandalf:

Hello,

Sorry for response delay.

Thank you for your point, however no luck for me trying it. Is it possible that it is because I use Kdyby\Annotations, so that lazy loading causes the extension not to be loaded because mailFactory that requires the IMailer interface in construct is inactive? That would explain why it appears on Tracy Bar only when sending a mail in the request.

4 years ago