Created
August 8, 2020 07:55
-
-
Save ismail1432/0729552e8fd6a669bdf5e174a43a8273 to your computer and use it in GitHub Desktop.
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 PostContentController | |
{ | |
/** | |
* @Route("/contents", name="post_content", methods="POST") | |
*/ | |
public function __invoke(NotifierInterface $notifier, Request $request) | |
{ | |
if(null !== $message = (\json_decode($request->getContent(), true)['message'] ?? null)) { | |
$notifier->send(new Notification($message, ['chat/linkedin'])); | |
return new JsonResponse('message posted with success', 201); | |
} | |
throw new BadRequestException('Missing "message" in body'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment