<?php
namespace App\Controller\Api\Mercure;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Mercure\HubInterface;
use Symfony\Component\Mercure\Update;
use Symfony\Component\Routing\Annotation\Route;
class SignalKYCAgentLiveController extends AbstractController
{
/**
* @Route("/mercure/signal/{id}/kyc/on-progress", name="signal_kyc_on_progress", methods={"POST"})
*/
public function __invoke(HubInterface $hub, string $id, Request $request): JsonResponse
{
$user = $this->getUser();
$update = new Update(
'http://api.digidom.pro/signal/kyc/on-progress',
json_encode([
'organizationId' => $id,
'agent' => $user ? $user->getFullName() : 'Un Agent',
'content' => $request->query->get('content', 'contrat'),
], JSON_THROW_ON_ERROR)
);
$hub->publish($update);
return new JsonResponse('published!');
}
}