src/Controller/Api/Mercure/SignalKYCAgentLiveController.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Controller\Api\Mercure;
  3. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  4. use Symfony\Component\HttpFoundation\JsonResponse;
  5. use Symfony\Component\HttpFoundation\Request;
  6. use Symfony\Component\Mercure\HubInterface;
  7. use Symfony\Component\Mercure\Update;
  8. use Symfony\Component\Routing\Annotation\Route;
  9. class SignalKYCAgentLiveController extends AbstractController
  10. {
  11.     /**
  12.      * @Route("/mercure/signal/{id}/kyc/on-progress", name="signal_kyc_on_progress", methods={"POST"})
  13.      */
  14.     public function __invoke(HubInterface $hubstring $idRequest $request): JsonResponse
  15.     {
  16.         $user $this->getUser();
  17.         $update = new Update(
  18.             'http://api.digidom.pro/signal/kyc/on-progress',
  19.             json_encode([
  20.                 'organizationId' => $id,
  21.                 'agent' => $user $user->getFullName() : 'Un Agent',
  22.                 'content' => $request->query->get('content''contrat'),
  23.             ], JSON_THROW_ON_ERROR)
  24.         );
  25.         $hub->publish($update);
  26.         return new JsonResponse('published!');
  27.     }
  28. }