我想知道控制器中的資產名稱。我使用資產,因此資產名稱是隨機的。Symfony - 使用資產查找資產名稱
例如,對於我的CSS,在我的枝條我:
{% block stylesheets %}
{% stylesheets filter='uglifycss' filter='cssrewrite'
'assets/css/bootstrap.min.css'
'assets/css/core.css'
%}
<link rel="stylesheet" href="{{ asset(asset_url) }}" />
{% endstylesheets %}
{% endblock %}
結果:現在
<link rel="stylesheet" href="http://local.example.com/css/c491e8f-285c78f.css" />
,我想在我的控制器自動查找名稱c491e8f-285c78f.css
。 我想:
var_dump($this->get('assetic.asset_manager')->getNames(),
$this->get('assetic.asset_manager')->get('c491e8f')->getTargetPath());
結果:
array(3) {
[0] => string(7) "c491e8f"
[1] => string(7) "b011b98"
[2] => string(7) "f4e7a09"
}
string(35) "_controller/css/c491e8f-285c78f.css"
它不壞,但我已經被騙找到「c491e8f」名字......我怎麼能知道這是我的CSS資產名稱?我如何自動找到資產路徑?