Created
November 18, 2015 06:38
-
-
Save cod3beat/9b049c5cacbb6cc52aed to your computer and use it in GitHub Desktop.
Publishing Unpublished Challenge
This file contains hidden or 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 | |
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