thephpleague / tactician-bundle

Bundle to integrate Tactician with Symfony projects
MIT License
245 stars 43 forks source link

Added alias to allow autowiring of default commandbus #100

Closed felixgomez closed 6 years ago

felixgomez commented 6 years ago

As Symfony 3.4+ enables autowiring by default, it would be a good idea to autowire the default command bus (just an alias required) to allow use it as follows

<?php 

namespace AppBundle\Controller;

use League\Tactician\CommandBus;
use AppBundle\Commands\DoSomethingCommand;

class YourNameController
{
    public function doSomething(CommandBus $commandBus)
    {
        $command = new DoSomethingCommand();
        $commandBus->handle($command);
    }
}

What do you think?

rosstuck commented 6 years ago

Hi @felixgomez! Thanks for your PR. :)

Normally I recommend folks wrap Tactician in a bridge and typehint against that instead (it's part of the reason there's not an interface for the bus itself). But honestly, I'm okay with this too.

If anyone else has any feedback, I'll leave this open for the weekend but otherwise, I'll merge it. :+1:

rosstuck commented 6 years ago

Also, congrats on being PR/issue #100! :confetti_ball: