Fixing Twig forms.resource deprecation in Symfony 3.3

439 views Asked by At

The Bundle https://github.com/saadtazi/SaadTaziGChartBundle (version 2.0) passes "twig.form.resources" as an argument.

<?xml version="1.0" ?>
<container xmlns="http://symfony.com/schema/dic/services"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">

    <parameters>
        <parameter key="twig.extension.g_chart.class">SaadTazi\GChartBundle\Twig\GChartExtension</parameter>
        <parameter key="twig.extension.visualization.template">SaadTaziGChartBundle:chart:visualizationChart.html.twig</parameter>
    </parameters>

    <services>
        <service id="twig.extension.g_chart" class="%twig.extension.g_chart.class%">
            <tag name="twig.extension" alias="g_chart" />
            <argument key="twig.form.resources" type="collection">
                <argument key="gChartTemplate">%twig.extension.visualization.template%</argument>
            </argument>

        </service>
    </services>
</container>

This configuration throws an Exception in Syfony 3.3:

Invalid key "twig.form.resources" found in arguments of method "__construct()" for service "twig.extension.g_chart": only integer or $named arguments are allowed.

The constructor has a resources property:

   /**
     * @param array $resources a list of resources (see Resources/g_chart.xml)
     */
    public function __construct(array $resources = array()) {
        $this->resources = $resources;
    }

I've tried fixing it by passing "twig.form_themes", which is the replacement for "twig.form.resources", but that throws an Exception too. Any thoughts appreciated, thanks!

0

There are 0 answers