deblan.io-murph/src/Controller/Blog/Api/CommentController.php

21 lines
694 B
PHP
Raw Normal View History

2021-03-30 13:47:58 +02:00
<?php
namespace App\Controller\Blog\Api;
2021-03-30 20:40:36 +02:00
use App\Markdown\Parser\Comment as CommentParser;
2021-03-30 13:47:58 +02:00
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
2021-03-30 20:40:36 +02:00
use Symfony\Component\Routing\Annotation\Route;
2021-03-30 13:47:58 +02:00
class CommentController extends AbstractController
{
2022-11-19 20:42:30 +01:00
#[Route(path: '/api/blog/comment/preview', name: 'api_blog_comment_preview', options: ['expose' => true])]
2021-03-30 13:47:58 +02:00
public function preview(Request $request, CommentParser $parser): JsonResponse
{
return $this->json([
'render' => $parser->transformMarkdown($request->request->get('content')),
]);
}
}