Skip to content

Named aliases for each available launcher #101

@yann-eugone

Description

@yann-eugone

Description
We can have several job launcher in the same application.

We might want to rely on only one, and thus use the one configured to be autowired with the interface.

But we might also want to use different one based on some arbitrary decision.

But because of testing, we do not want to rely on the actual class name.

Example

<?php

namespace App\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Yokai\Batch\Launcher\JobLauncherInterface;

class Controller extends AbstractController
{
    public function action(
        JobLauncherInterface $simpleJobLauncher,
        JobLauncherInterface $consoleJobLauncher,
        JobLauncherInterface $messengerJobLauncher,
    ): Response {
        /...
    }
}

I should receive

  • in $simpleJobLauncher: Yokai\Batch\Launcher\SimpleJobLauncher
  • in $consoleJobLauncher: Yokai\Batch\Bridge\Symfony\Console\RunCommandJobLauncher
  • in $messengerJobLauncher: Yokai\Batch\Bridge\Symfony\Messenger\DispatchMessageJobLauncher

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions