Created
March 1, 2015 18:39
-
-
Save petersuhm/82332482b770531dcb76 to your computer and use it in GitHub Desktop.
Command handler locator for Tactician (http://tactician.thephpleague.com/).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace WpShipper\Handlers\Commands; | |
use Illuminate\Foundation\Application; | |
use League\Tactician\Command; | |
use League\Tactician\Handler\Locator\HandlerLocator; | |
class LaravelHandlerLocator implements HandlerLocator | |
{ | |
/** | |
* @var Application | |
*/ | |
private $app; | |
public function __construct(Application $app) | |
{ | |
$this->app = $app; | |
} | |
/** | |
* Retrieves the handler for a specified command | |
* | |
* @param Command $command | |
* @return mixed | |
*/ | |
public function getHandlerForCommand(Command $command) | |
{ | |
$commandClass = get_class($command); | |
$handlerClass = str_replace('Commands', 'Handlers\Commands', $commandClass) . 'Handler'; | |
return $this->app->make($handlerClass); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment