Autowire problem since 1.2 because of $translator
As $translator has no type-hint anymore in the AbstractDatatable class, I get an error when defining my Datatable like that
This is a datatable.yaml file imported in services.yaml
services:
_defaults:
autowire: true # Automatically injects dependencies in your services.
autoconfigure: true # Automatically registers your services as commands, event subscribers, etc.
public: true
App\Datatables\UserDatatable:
parent: sg_datatables.datatable.abstract
autowire: true
autoconfigure: false
public: true
Well it says that $translator has no type-hint and should be configured explicitally.
Translator has been typed object in DatatableFactory for legacy purposes. You can pass the translator in your config as such :
Sg\DatatablesBundle\Datatable\DatatableFactory:
arguments: ['', '', '@translator', '', '', '']
You can add a constructor to your UserDatatable class , If you insist on creating the service that's okay but with the default configuration a service is created automatically (Symfony 4)
use Symfony\Contracts\Translation\TranslatorInterface;
public function __construct(
AuthorizationCheckerInterface $authorizationChecker,
TokenStorageInterface $securityToken,
TranslatorInterface $translator,
RouterInterface $router,
EntityManagerInterface $em,
Environment $twig
)
{
parent::__construct($authorizationChecker, $securityToken, $translator, $router, $em, $twig);
}
To check if your service exists
php bin/console debug:container App\Datatables\UserDatatable