35 lines
1.1 KiB
PHP
35 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Controller;
|
|
|
|
use App\Entity\Actions;
|
|
use App\Entity\Organizations;
|
|
use App\Service\ActionService;
|
|
use Doctrine\ORM\EntityManagerInterface;
|
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
|
use Symfony\Component\HttpFoundation\JsonResponse;
|
|
use Symfony\Component\Routing\Annotation\Route;
|
|
|
|
#[Route(path: '/actions', name: 'actions_')]
|
|
class ActionController extends AbstractController
|
|
{
|
|
public function __construct(
|
|
private EntityManagerInterface $entityManager,
|
|
private ActionService $actionService
|
|
) {
|
|
}
|
|
|
|
#[Route('/organization/{id}/activities-ajax', name: 'app_organization_activities_ajax', methods: ['GET'])]
|
|
public function fetchActivitiesAjax(Organizations $organization): JsonResponse
|
|
{
|
|
$actions = $this->entityManager->getRepository(Actions::class)->findBy(
|
|
['Organization' => $organization],
|
|
['date' => 'DESC'],
|
|
15
|
|
);
|
|
$formattedActivities = $this->actionService->formatActivities($actions);
|
|
|
|
return new JsonResponse($formattedActivities);
|
|
}
|
|
}
|