Skip to content

Instantly share code, notes, and snippets.

@ismail1432
Created August 8, 2020 07:55
Show Gist options
  • Save ismail1432/0729552e8fd6a669bdf5e174a43a8273 to your computer and use it in GitHub Desktop.
Save ismail1432/0729552e8fd6a669bdf5e174a43a8273 to your computer and use it in GitHub Desktop.
<?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