src/Controller/Api/Mercure/SignalKYCFinishedController.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 SignalKYCFinishedController extends AbstractController
  10. {
  11.     /**
  12.      * @Route("/mercure/signal/{id}/kyc/finished", name="signal_kyc_finished", methods={"POST"})
  13.      * Allows us to push the information that KYC is completed so that all admins can see their dashboards update.
  14.      */
  15.     public function __invoke(HubInterface $hubstring $idRequest $request): JsonResponse
  16.     {
  17.         $update = new Update(
  18.             'http://api.digidom.pro/signal/kyc/finished',
  19.             json_encode([
  20.                 'organizationId' => $id,
  21.                 'status' => 'finished',
  22.             ], JSON_THROW_ON_ERROR)
  23.         );
  24.         $hub->publish($update);
  25.         return new JsonResponse('published!');
  26.     }
  27. }