简体   繁体   English

如何设置Symfony WebProfiler的应用程序版本?

[英]How to set application version for Symfony WebProfiler?

according to this commit you can set your own application name and version for the WebProfiler. 根据此提交,您可以为WebProfiler设置自己的应用程序名称和版本。 Now I'm asking myself (and you ^^) what's the intended way to do this? 现在,我问自己(和你^^)打算这样做的目的是什么?

/**
 * 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;
 }

The collector is defined in ConfigDataCollector of the HttpKernel component and its constructor has two parameters defaulting to null . 收集器在HttpKernel组件的ConfigDataCollector中定义,其构造函数有两个参数默认为null The service is configured in the collectors.xml of the FrameWorkBundle , but there's no way to set the parameters. 该服务是在FrameWorkBundlecollectors.xml中配置的,但是无法设置参数。

I've now overriden collector class by setting the data_collector.config.class in app/config/config.yml and injecting my application's version this way... but this totally feels wrong. 我现在已经通过设置重写收集类data_collector.config.classapp/config/config.yml和注入我的应用程序的版本这样......但是这完全觉得不妥。

Do I miss something? 我想念什么吗?

The commit message says (emphasis mine): 提交消息说(强调我的):

[WebProfiler] added the possibility to override the application name/version in the WDT [WebProfiler]添加了在WDT中覆盖应用程序名称/版本的可能性

I presume that the way to do it would be the way you did it, that is, use your own class that extends Symfony\\Component\\HttpKernel\\DataCollector\\ConfigDataCollector and override the constructor to set the properties ( name and version ). 认为这样做的方式就是您这样做的方式,即使用您自己的类扩展Symfony\\Component\\HttpKernel\\DataCollector\\ConfigDataCollector并重写构造函数以设置属性( nameversion )。

If someone knows a better way to do it, it'd be appreciated! 如果有人知道更好的方法,将不胜感激!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM