-
Notifications
You must be signed in to change notification settings - Fork 236
Symfony 4.2 DI issue #857
Comments
Hi ! #> php bin/console sg:datatable:generate AppBundle:Post Thank's by advance |
I believe this is for a different question. The above is for Symfony 4.2 that deprecated Controller for AbstractController and the modifications necessary to allow proper dependency injection. |
In addition the route annotations use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method; got superseded by a single use Symfony\Component\Routing\Annotation\Route; |
If you are encountering issue, feel free to submit a pull request. |
Starting with Symfony 4.2, Controller is deprecated, recommending AbstractController to be used.
However, by using AbstractController the 'old' way of getting the factory service no longer works.
Old:
$datatable = $this->get('sg_datatables.factory')->create(EntityDatatable::class);
The new way to use the datatables factory is to use dependency injection in the constructor of the controller.
This allows to access the factory:
$datatable = $this->dtFactory->create(EntityDatatable::class);
And the response:
$responseService = $this->dtResponse;
in the Ajax response portion of the function.However, now, Symfony complains:
The fix for this is in the
services.yaml
to add the following:At this point, everything should be working properly.
The text was updated successfully, but these errors were encountered: