So I am trying to wrap my head around how to set parameters via the BundleNameExtention
class that resides inside the DependencyInjection
folder of a bundle rather than defining them directly in config.yml
I am using a default AppBundle
that came with symfony install.
It seems pretty straight forward reading the documentation online that inside the load
method I should be able to set the parameters I want so this is what I did
namespace AppBundle\DependencyInjection;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\DependencyInjection\Loader;
class AppExtension extends Extension
{
public function load(array $configs, ContainerBuilder $container)
{
$loader = new Loader\xmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('services.xml');
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);
$config['comments'] = "some value";
$container->setParameter('app.comments', $config['comments']);
}
public function getAlias(){
return 'app';
}
}
How can I access this parameter in my twig template?