Symfony 4 get repository in template batch action

  action, symfony, symfony4

I use Symfony 4 and sonata admin.
I created a custom batch action in the member list. I would like to have access to the other repositories in the batch action template. I would like to be able to select products before sending it to the members.

How to pass the repository by batch action?

    $actions['sendProducts'] = [
        'label' => 'Envoyer les produits',
        'ask_confirmation' => true,
        'template' => 'send-products.html.twig'

In my template I would like to have a select with all the names of my products (created in my products entity).


Source: Symfony Questions