Skip to content

Instantly share code, notes, and snippets.

@sergigp
Last active August 29, 2015 14:27
Show Gist options
  • Save sergigp/915ab961b95a05aa4f38 to your computer and use it in GitHub Desktop.
Save sergigp/915ab961b95a05aa4f38 to your computer and use it in GitHub Desktop.
<?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;
}
};
}
}
@rgomezcasas
Copy link

Pole

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment