[英]Get assets urls from assetic group in controller (not template) Symfony2
I wonder if how could I load an assetic group of assets from inside my controller. 我想知道如何从控制器内部加载一组资产资产。
my config.yml: 我的config.yml:
assetic:
assets:
systemassets:
inputs:
- 'bundles/belkapanel/js/*.js'
- 'bundles/belkapanel/router.js'
Using twig, the solution is very simple: 使用细枝,解决方案非常简单:
{% javascripts '@systemassets'%}
<script src="{{ asset_url }}"></script>
{% endjavascripts %}
it will resolve the path wildcard and generate an single .js file with the content of all files found inside "systemassets". 它将解析路径通配符,并生成一个.js文件,其中包含在“ systemassets”中找到的所有文件的内容。
However, I want to get the generated .js file inside an controller. 但是,我想在控制器内部获取生成的.js文件。 I know it is possible, but reading the symfony's assetic-bundle I only found AsseticHelper with "javascripts" method, but I don't know how to use it, I think it is used after the packagename and wildcards are resolved.
我知道这是可能的,但是阅读symfony的assetic-bundle时,我仅使用“ javascripts”方法找到了AsseticHelper,但我不知道如何使用它,我认为它是在软件包名称和通配符解析后使用的。
/** @var DynamicAsseticHelper $asseticDynamic */
$asseticDynamic = $this->get('assetic.helper.dynamic');
$assets = $asseticDynamic->javascripts('systemassets'); // Doesn't work!
I'm looking at AsseticTokenParser, I think it is the solution, am I right? 我正在查看AsseticTokenParser,我认为这是解决方案,对吗? can someone help me find the solution?
有人可以帮助我找到解决方案吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.