Skip to content

Instantly share code, notes, and snippets.

@JeffreyWay
Last active February 9, 2019 05:17
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JeffreyWay/09cb26b77daf7fc1c95e to your computer and use it in GitHub Desktop.
Save JeffreyWay/09cb26b77daf7fc1c95e to your computer and use it in GitHub Desktop.
<?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