//Add below in a custom controller:
use Symfony\Component\Finder\Finder;
use Symfony\Component\Finder\SplFileInfo;
//...
$dir = './bundles/ibexaicons/img/icons/';
$finder = new Finder();
$finder->files()->in($dir);
/** @var SplFileInfo $file */
foreach ($finder as $file) {
$svgs[$file->getBasename('.svg')] = $file->getContents();
}
return $this->render(
'default.html.twig',
[
'svgs' => $svgs
]
);
{# add template in /templates/default.html.twig#}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
<div class="row">
{% for file,svg in svgs %}
<div class="col-md-2">
<div class="well">
<div>
{{ svg|raw }}
</div>
{{ file }}
</div>
</div>
{% if loop.index is divisible by(5) and not loop.last %}
</div>
<div class="row">
{% endif %}
{% endfor %}
<div>
<style>
svg{
width:50px;height: 50px
}
.col-md-2{text-align: center}
</style>