mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 07:03:49 +00:00
Fixed: filter social action to keep only currently activated
This commit is contained in:
@@ -16,21 +16,19 @@ use Chill\MainBundle\Pagination\PaginatorFactory;
|
||||
use Chill\MainBundle\Serializer\Model\Collection;
|
||||
use Chill\PersonBundle\Entity\SocialWork\SocialAction;
|
||||
use Chill\PersonBundle\Repository\SocialWork\SocialIssueRepository;
|
||||
use Symfony\Component\Clock\ClockInterface;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
use function count;
|
||||
|
||||
class SocialWorkSocialActionApiController extends ApiController
|
||||
final class SocialWorkSocialActionApiController extends ApiController
|
||||
{
|
||||
private PaginatorFactory $paginator;
|
||||
|
||||
private SocialIssueRepository $socialIssueRepository;
|
||||
|
||||
public function __construct(SocialIssueRepository $socialIssueRepository, PaginatorFactory $paginator)
|
||||
{
|
||||
$this->socialIssueRepository = $socialIssueRepository;
|
||||
$this->paginator = $paginator;
|
||||
public function __construct(
|
||||
private readonly SocialIssueRepository $socialIssueRepository,
|
||||
private readonly PaginatorFactory $paginator,
|
||||
private readonly ClockInterface $clock,
|
||||
) {
|
||||
}
|
||||
|
||||
public function listBySocialIssueApi($id, Request $request)
|
||||
@@ -42,7 +40,10 @@ class SocialWorkSocialActionApiController extends ApiController
|
||||
throw $this->createNotFoundException('socialIssue not found');
|
||||
}
|
||||
|
||||
$socialActions = $socialIssue->getRecursiveSocialActions()->toArray();
|
||||
$socialActions = SocialAction::filterRemoveDeactivatedActions(
|
||||
$socialIssue->getRecursiveSocialActions()->toArray(),
|
||||
\DateTime::createFromImmutable($this->clock->now())
|
||||
);
|
||||
|
||||
usort($socialActions, static fn (SocialAction $sa, SocialAction $sb) => $sa->getOrdering() <=> $sb->getOrdering());
|
||||
|
||||
|
Reference in New Issue
Block a user