Last active
February 9, 2019 05:17
-
-
Save JeffreyWay/09cb26b77daf7fc1c95e to your computer and use it in GitHub Desktop.
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 Acme\Jobs; | |
use Acme\Commanding\CommandHandler; | |
use Acme\Eventing\EventDispatcher; | |
class PostJobListingCommandHandler implements CommandHandler { | |
protected $dispatcher; | |
protected $repository; | |
function __construct(EventDispatcher $dispatcher, JobRepository $repository) | |
{ | |
$this->dispatcher = $dispatcher; | |
$this->repository = $repository; | |
} | |
public function handle($command) | |
{ | |
$job = Job::publish($command->title, $command->description); | |
$this->repository->save($job); | |
$this->dispatcher->dispatch($job->releaseEvents()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment