a18e1f575f
- drop ClientPortal module, ClientTicket entity, ROLE_CLIENT and all couplings (Task, TaskDocument, User, Notification) back to an internal-only model - migration drops client_ticket / user_allowed_projects / related FK columns and removes leftover external client accounts (would otherwise be promoted to ROLE_USER) - remove client-portal frontend module, admin tickets tab, user portal section, portal nav item and portal/clientTicket i18n keys - fix directory nav icon (invalid mdi:contact-multiple-outline -> mdi:card-account-details-outline) - add 'make sync-permissions' target, wire it into install/db-reset and the prod deploy script
57 lines
1.6 KiB
PHP
57 lines
1.6 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Module\ProjectManagement\Infrastructure\ApiPlatform\State;
|
|
|
|
use ApiPlatform\Metadata\Operation;
|
|
use ApiPlatform\State\ProviderInterface;
|
|
use App\Module\ProjectManagement\Domain\Entity\TaskDocument;
|
|
use App\Shared\Domain\Contract\UserInterface;
|
|
use Doctrine\ORM\EntityManagerInterface;
|
|
use Symfony\Bundle\SecurityBundle\Security;
|
|
|
|
/**
|
|
* @implements ProviderInterface<TaskDocument>
|
|
*/
|
|
final readonly class TaskDocumentProvider implements ProviderInterface
|
|
{
|
|
public function __construct(
|
|
private EntityManagerInterface $entityManager,
|
|
private Security $security,
|
|
) {}
|
|
|
|
public function provide(Operation $operation, array $uriVariables = [], array $context = []): array|TaskDocument|null
|
|
{
|
|
$user = $this->security->getUser();
|
|
assert($user instanceof UserInterface);
|
|
|
|
$repo = $this->entityManager->getRepository(TaskDocument::class);
|
|
|
|
// Single item
|
|
if (isset($uriVariables['id'])) {
|
|
return $repo->find($uriVariables['id']);
|
|
}
|
|
|
|
// Collection
|
|
$qb = $repo->createQueryBuilder('d')
|
|
->orderBy('d.id', 'DESC')
|
|
;
|
|
|
|
// Apply filters from query parameters
|
|
$filters = $context['filters'] ?? [];
|
|
if (isset($filters['task'])) {
|
|
$qb->andWhere('d.task = :task')
|
|
->setParameter('task', self::extractId($filters['task']))
|
|
;
|
|
}
|
|
|
|
return $qb->getQuery()->getResult();
|
|
}
|
|
|
|
private static function extractId(string $value): int
|
|
{
|
|
return is_numeric($value) ? (int) $value : (int) basename($value);
|
|
}
|
|
}
|