[WebProfiler] added the possibility to override the application name/version in the WDT
This commit is contained in:
parent
03fc97d11a
commit
d35cb9f880
@ -5,15 +5,26 @@
|
||||
{% set icon %}
|
||||
<a href="http://symfony.com/">
|
||||
<img width="26" height="28" alt="Symfony" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABoAAAAcCAMAAABIzV/hAAACZFBMVEUwLjL///////////////////////////////////////////////////////////////////+Eg4b///+Ni46Xlpj///////////+op6n///////////////////////////////////////////////////////////9ZWFv///////9qaWz///////+mpaf///////////////9ZWFv///////////////9PTVH///91dHb////////////////////g4OD///9NTE+Ih4r///////+Ni47///////92dHeRkJLk5OTLy8xlY2b///////+cm53///////+5ubr////o6Oj////////U1NT///9DQURsa22rq6ysq61hX2L///+LioxTUVVBP0NEQkZpZ2rGxsf///9ram3////s7O2SkZNfXmFxcHKmpae4uLnKysuXlpiop6l3dXiIh4pYVlmrq6ycm52trK7Nzc48Oj5dW158e36dnJ49Oz/Pz9BiYGPAv8BDQUTQz9BVU1aioaNHRUnBwcJXVVk6ODxJR0t3dnmko6U8Oj6lpKY9Oz+0tLXDwsRQTlF7en1QTlHi4eJhX2LFxcZTUVViYGNwb3J+fX83NTlFQ0dUUlW4t7icm524uLk8Oj5YVlmPjpBLSU2enZ9aWVw/PkFBP0NdW153dnk0MjZQTlE1MzdQT1JdXF9ram15eHqGhYdDQkV5eHo2NThEQkZRUFNFQ0dta244NjpGREhTUVU5NztUUlVhX2JubG9HRUlVU1ZiYGM7OTxIRkk7OT1IR0o8Oj4wLjI9Oz8YdG13AAAAynRSTlMAAAEDBAUGCgsMDQ4QEhMUGRobGx0gISIkJiYnKCktLi8wMjM0NTk6Ozw+P0NFSEpLTE5PUFBTWlteXmBiZGVmaWxtcHBxc3R0dnl5fX+BgoOGi46Pj5CRmZqanZ6eoKeoq6ytsLCwsrO0tbe5urq8vL+/wsTFx8jJycvLy8vM0NHR0tLU1NfX2NnZ2trc3N3d3eHh4uLl5ebm5ubn5+fo6urt7e3u7vDx8/Pz9PT19fX19fX29vf39/j4+fn5+vr6+vv7+/z8/f3+yR5EtwAAAbVJREFUeNpl0mVXVFEYhuF3zhkOFqMjYmCi2MUYYKGIYiJ2YCd2t4IBFqgoKjZ2jg3igI2KyO2f8sTMngGvj/te71r7wyMuk4jofZccAihcMzJKXDYnuYcVotyeYKiktV5LA0faaE7S4s7TyMsBupnMcoH/vO6gmanJaiLV1Py+Xwn5zc0fjCbSi2LI2QdkGdLyFBG+rHwMzz4BD7wyGEfFk8pfsD2TkGmyFNvFHfDj55v02VD6DcteOYylatY8oG7boA2QV4vlklzB8tU3/DIwo+dWv58guY5tRcLMtwSGdi1DkTvAn9Jqsgbu4kafRBqlV4sDFCWuIjdhMsp7yQU49rB28/QPLOu2DuWqLMfmfw6M716GskdGVRMSGDKRsEzpvZ+Qs0lFKDd94s2oArh2F7K3oNQt6ChGr5x6+Dx3J7d2E3Ygqam4PCkngRNnngYIO5cWq4lLb5t+vJ6GiifFR1nbMNqP3fSOCN8PZnQynEW5W/nmHy0PXv79eHpRSjsjtEOtWZcRc9YXlNx7VFKwceGYHjG6s0Ob3iK+X3LqlKnjkvt39rjD6w3W6BhvrCdaVw//ADrWicJIvtkmAAAAAElFTkSuQmCC"/>
|
||||
<span>{{ collector.symfonyversion }}</span>
|
||||
<span>
|
||||
{% if collector.applicationname %}
|
||||
{{ collector.applicationname }} {{ collector.applicationversion }}
|
||||
{% else %}
|
||||
{{ collector.symfonyversion }}
|
||||
{% endif %}
|
||||
</span>
|
||||
</a>
|
||||
{% endset %}
|
||||
{% set text %}
|
||||
{% if collector.applicationname %}
|
||||
<div class="sf-toolbar-info-piece">
|
||||
{{ collector.applicationname }} <b>{{ collector.applicationversion }}</b>
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="sf-toolbar-info-piece">
|
||||
Symfony <b>{{ collector.symfonyversion }}</b>
|
||||
</div>
|
||||
<div class="sf-toolbar-info-piece">
|
||||
<a href="http://symfony.com/doc/{{ collector.symfonyversion }}/index.html" rel="help">Documentation</a>
|
||||
<a href="http://symfony.com/doc/{{ collector.symfonyversion }}/index.html" rel="help">Symfony Documentation</a>
|
||||
</div>
|
||||
{% endset %}
|
||||
{% include '@WebProfiler/Profiler/toolbar_item.html.twig' with { 'link': false } %}
|
||||
@ -97,8 +108,13 @@
|
||||
<th>Value</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Symfony version</th>
|
||||
<td>{{ collector.symfonyversion }}</td>
|
||||
{% if collector.applicationname %}
|
||||
<th>Application</th>
|
||||
<td>{{ collector.applicationname }} {{ collector.applicationversion }} (on Symfony {{ collector.symfonyversion }})</td>
|
||||
{% else %}
|
||||
<th>Symfony version</th>
|
||||
<td>{{ collector.symfonyversion }}</td>
|
||||
{% endif %}
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Application name</th>
|
||||
|
@ -25,10 +25,24 @@ use Symfony\Component\HttpFoundation\Response;
|
||||
class ConfigDataCollector extends DataCollector
|
||||
{
|
||||
private $kernel;
|
||||
private $name;
|
||||
private $version;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $name The name of the application using the web profiler
|
||||
* @param string $version The version of the application using the web profiler
|
||||
*/
|
||||
public function __construct($name = null, $version = null)
|
||||
{
|
||||
$this->name = $name;
|
||||
$this->version = $version;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Kernel associated with this Request.
|
||||
*
|
||||
* @param KernelInterface $kernel A KernelInterface instance
|
||||
*/
|
||||
public function setKernel(KernelInterface $kernel = null)
|
||||
@ -42,6 +56,8 @@ class ConfigDataCollector extends DataCollector
|
||||
public function collect(Request $request, Response $response, \Exception $exception = null)
|
||||
{
|
||||
$this->data = array(
|
||||
'app_name' => $this->name,
|
||||
'app_version' => $this->version,
|
||||
'token' => $response->headers->get('X-Debug-Token'),
|
||||
'symfony_version' => Kernel::VERSION,
|
||||
'name' => isset($this->kernel) ? $this->kernel->getName() : 'n/a',
|
||||
@ -64,6 +80,16 @@ class ConfigDataCollector extends DataCollector
|
||||
}
|
||||
}
|
||||
|
||||
public function getApplicationName()
|
||||
{
|
||||
return $this->data['app_name'];
|
||||
}
|
||||
|
||||
public function getApplicationVersion()
|
||||
{
|
||||
return $this->data['app_version'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the token.
|
||||
*
|
||||
|
Reference in New Issue
Block a user