It's posible to log to Zend Developer Tools toolbar some variable in ZF2 controller?
相关问题
- Why does recursive submodule update from github fa
- How to pass options/params to formCollection field
- Compress html output from zend framework 2
- zend smtp mail crashes after 100+ mails
- Add a developer to my Facebook App
相关文章
- Zend Framework 2 Forms Array notation for drop dow
- Use spiffy navigation with zfcrbac module
- Best practice to call another controller action fr
- How to use Zend Service Amazon?
- Difference between init() and onBootStrap() in Zen
- Does Zend Framework 2.0 leave out the amazon s3 li
- Zend Framework 2 Flash Messenger returning no mess
- doctrine migrations 2 + zend framework 2 = is it p
Well, I have created a Collector to add personal information on ZendDevelopersTool. You need info from a Controller, and that's I never had tried to do. :)
I gonna show you how I created the Collector, and maybe you can find some way to take info from the Controller.
In your
MyModule\module.config.php
On
MyModule\Module.php
, you need to load your invokables, I'm doing this by adding the following method:Add a
.phtml
file on the on your views:And add, for example:
Now, the final part! We need to create a Collector, that gonna grab all teh information we wanna display:
This Class have methods, like
getDefaultLocale()
, and we use them onzend-developer-tools/toolbar/mymodule-configs.phtml
.It should look like this:
You can try to adapt this piece of code, to fit your needs. And please, if you find out how to grab info from your controller, share with us!
Edit
In the
ConfigCollector
class, pay attention to the methodcollect(MvcEvent $mvcEvent)
.As you can see, you have a MvcEvent object there. Maybe you can pass your personal info using it.
You can also use my package that alow log any data to bar and use Tracy/Debugger to highlight and add tree to your dumped data.
renat-magadiev/zf3-bar-logger
so you can simply write:
or simply using global function in shortcuts:
preview
More briefly, it's possible : ) I'm not proud about the way I did it, but - well known excuse - it works. And if you have any suggestions, I'll be not glad but happy to hear them.
How to create a custom collector @vinigarcia87 explained above.
To log something in Controller(and in any other place) and then grab that data in the collector I made a new class in my module with a static field and static getter/setter, which I use as a proxy. Here is some code:
In a controller's action:
And in collector collect method:
This messages are now accessible in toolbar entry .pthml file this way:
<?php \Zend\Debug\Debug::dump($this->collector->getMessages()); ?>
Your opinions...