Skip to content

Instantly share code, notes, and snippets.

@cod3beat
Created November 18, 2015 06:38
Show Gist options
  • Save cod3beat/9b049c5cacbb6cc52aed to your computer and use it in GitHub Desktop.
Save cod3beat/9b049c5cacbb6cc52aed to your computer and use it in GitHub Desktop.
Publishing Unpublished Challenge
<?php
class PublishUnpublishedChallengeHandler
{
public function handle(PublishUnpublishedChallenge $command)
{
try {
DB::beginTransaction();
$publishedChallenge = $this->challengePublicationContext->publishUnpublishedChallenge($command->challenge_id);
$this->memberMailer->send($publishedChallenge->getChallengeOwner(), 'Congrats, your Challenge Has Been Published');
$this->feedRepository->add($publishedChallenge);
$this->tweetStream->add('A new challenge has been published');
$this->eventLog->log($publishedChallenge);
DB::commit();
} catch (Exception $e) {
DB::rollback();
throw $e;
}
return new PublishUnpublishedChallengeResponse($publishedChallenge);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment