I'm looking to create a twig extension but Symfony keeps telling me my function is unknown.
Here is my class:
<?php
namespace AppBundle\Twig\Extension;
use Twig_Extension;
use Twig_SimpleFunction;
class FormExtension extends Twig_Extension
{
public function getFonctions()
{
$twigClass = 'Symfony\Bridge\Twig\Node\SearchAndRenderBlockNode';
$options = array(
'node_class' => $twigClass,
'is_safe' => ['html']
);
return array(
'form_color' => new Twig_SimpleFunction($this, null, $options)
);
}
public function getName()
{
return 'app_form_extension';
}
}
And here is the service declaration in AppBundle\Resources\config\services.yml
services:
app.form_extension:
class: AppBundle\Twig\Extension\FormExtension
tags:
- { name: twig.extension }
I'm probably missing somehing but I can't find out what. Please help!