<?php
namespace App\Controller;
use App\Library\Event\demoSendEvent;
use App\Library\Event\testEvent;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\JsonResponse;
use App\Library\Database;
use App\Library\Grapper;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
class ApiController extends AbstractController
{
public function __construct(private EventDispatcherInterface $dispatcher)
{
}
#[Route('/api/demo.{email}.{acid}.{adid}', name: 'app_demo')]
public function demoSend(string $email, int $acid, int $adid=0):JsonResponse{
$event = new demoSendEvent($email, $acid, $adid);
$this->dispatcher->dispatch($event);
return $event->getResponse();
}
#[Route('/api/test.{email}.{acid}', name: 'app_test')]
public function testSend(string $email, int $acid):JsonResponse{
$event = new testEvent($email, $acid);
$this->dispatcher->dispatch($event);
return $event->getResponse();
}
#[Route('/ping', name: 'ping')]
public function pingAction():Response
{
return new Response('pong');
}
}