first commit symfony 6
This commit is contained in:
27
src/Controller/PublishController.php
Normal file
27
src/Controller/PublishController.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
namespace App\Controller;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Mercure\HubInterface;
|
||||
use Symfony\Component\Mercure\Update;
|
||||
|
||||
class PublishController extends AbstractController
|
||||
{
|
||||
public function publish($channel, $id, Request $request, HubInterface $hub): Response
|
||||
{
|
||||
$ret=$request->get("msg");
|
||||
$ret["from"]=[];
|
||||
$ret["from"]["id"]="tot";
|
||||
$update = new Update(
|
||||
$channel."-".$id,
|
||||
json_encode(
|
||||
['ret' => $ret])
|
||||
);
|
||||
|
||||
$hub->publish($update);
|
||||
|
||||
return new Response('published!');
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user