Adding custom opération
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
6141f4e2ca
commit
4b151bc52f
@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Controller;
|
||||||
|
|
||||||
|
use App\Repository\PostRepository;
|
||||||
|
use Doctrine\ORM\EntityManager;
|
||||||
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
use Symfony\Component\Routing\Attribute\Route;
|
||||||
|
use App\Entity\Profil;
|
||||||
|
use Symfony\Component\HttpKernel\Attribute\AsController;
|
||||||
|
|
||||||
|
#[AsController]
|
||||||
|
class ProfilController extends AbstractController
|
||||||
|
{
|
||||||
|
|
||||||
|
public function __construct(private PostRepository $postRepository,private EntityManager $entityManager) {}
|
||||||
|
|
||||||
|
#[Route('/api/profils/{id}/post/follow', name: 'app_profil_followed')]
|
||||||
|
public function index(int $id): Response
|
||||||
|
{
|
||||||
|
$profil = $this->entityManager->find(Profil::class,$id);
|
||||||
|
if ($profil instanceof Profil) {
|
||||||
|
return new Response('',200,$this->postRepository->getPostFromFollowed($profil));
|
||||||
|
}
|
||||||
|
return new Response('',400);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,20 @@
|
|||||||
|
{% extends 'base.html.twig' %}
|
||||||
|
|
||||||
|
{% block title %}Hello ProfilController!{% endblock %}
|
||||||
|
|
||||||
|
{% block body %}
|
||||||
|
<style>
|
||||||
|
.example-wrapper { margin: 1em auto; max-width: 800px; width: 95%; font: 18px/1.5 sans-serif; }
|
||||||
|
.example-wrapper code { background: #F5F5F5; padding: 2px 6px; }
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<div class="example-wrapper">
|
||||||
|
<h1>Hello {{ controller_name }}! ✅</h1>
|
||||||
|
|
||||||
|
This friendly message is coming from:
|
||||||
|
<ul>
|
||||||
|
<li>Your controller at <code>/home/Koroh/Repos/Fukashitapi/src/Controller/ProfilController.php</code></li>
|
||||||
|
<li>Your template at <code>/home/Koroh/Repos/Fukashitapi/templates/profil/index.html.twig</code></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
Loading…
Reference in new issue