PHP code example of intaro / twig-injection-bundle
1. Go to this page and download the library: Download intaro/twig-injection-bundle library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
intaro / twig-injection-bundle example snippets
// app/AppKernel.php
public function registerBundles()
{
$bundles = [
//...
new Intaro\TwigInjectionBundle\IntaroTwigInjectionBundle(),
];
//...
}
namespace Acme\DemoBundle\EventListener;
use Intaro\TwigInjectionBundle\Event\TwigInjectEvent;
use Intaro\TwigInjectionBundle\Event\TwigInjectRender;
class TwigInjectionListener
{
public function onSomeEvent(TwigInjectEvent $event)
{
$parameters = $event->getParameters();
if (!isset($parameters['parameter1']) || 'some-value' !== $parameters['parameters1']) {
return;
}
$render = new TwigInjectRender(
'AcmeDemoBundle:DefaultController:index',
[ 'object' => $parameters['parameters2'] ]
);
$event->addInjection($render);
$