Last active
August 29, 2015 14:27
-
-
Save sergigp/915ab961b95a05aa4f38 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 | |
use ....; | |
final class GiftPostController | |
{ | |
private $exceptions = []; | |
public function __invoke(Request $request) | |
{ | |
$senderUserId = $request->attributes->get('authenticated_id'); | |
apply($this->sendCommand($senderUserId), $request->request->get('friends_ids')); | |
// see exceptions in order to compose response | |
return new ApiHttpCreatedResponse(); | |
} | |
private function sendCommand($senderUserId) | |
{ | |
return function ($receiverUserId) use ($senderUserId) { | |
try { | |
$command = new SendGiftsToFriendsCommand( | |
[ | |
'senderUserId' => $senderUserId, | |
'receiverUserId' => $receiverUserId, | |
] | |
); | |
$this->publish($command); | |
} catch (FuckingException $e) { | |
$this->exceptions[] = $e; | |
} | |
}; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Pole