90682e809c
LST-68 (2.6) backend. Behaviour-preserving move of the external integrations into src/Module/Integration/. All 26 routes and securities unchanged. - 5 entities (4 *Configuration singletons + TaskBookStackLink) + 5 repositories (Domain interfaces + Doctrine impls, bound). TaskBookStackLink.task now references TaskInterface (contract). - Domain (FileSource interface, SharePathResolver, share DTOs + exceptions); Infrastructure (GiteaApiService, BookStackApiService, SmbFileSource, 15 ApiResources, 21 State, 4 Share controllers). - Cross-module couplings via abstractions: CalDavService (PM) injects ZimbraConfigurationRepositoryInterface; PM TaskDocument consumers repointed to the module's FileSource/SharePathResolver; Gitea/BookStack State load tasks via TaskRepositoryInterface (concrete Project read for integration fields — documented). ZimbraTestConnection keeps CalDavService (no build cycle). TokenEncryptor stays shared. - IntegrationModule registered; doctrine mapping added. - #[Auditable] + Timestampable on the 4 Configuration entities (additive migration on the 4 *_configuration tables). 163 tests green, container compiles (no cycle), no route regression, cs-fixer clean.
57 lines
2.0 KiB
PHP
57 lines
2.0 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Module\Integration\Infrastructure\Controller;
|
|
|
|
use App\Module\Integration\Domain\Exception\ShareConnectionException;
|
|
use App\Module\Integration\Domain\Exception\ShareNotConfiguredException;
|
|
use App\Module\Integration\Domain\Service\FileEntry;
|
|
use App\Module\Integration\Domain\Service\FileSource;
|
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
|
use Symfony\Component\HttpFoundation\JsonResponse;
|
|
use Symfony\Component\HttpFoundation\Request;
|
|
use Symfony\Component\Routing\Attribute\Route;
|
|
use Symfony\Component\Security\Http\Attribute\IsGranted;
|
|
|
|
class ShareSearchController extends AbstractController
|
|
{
|
|
/** Longueur minimale du terme de recherche (évite un parcours global trop large). */
|
|
private const int MIN_QUERY_LENGTH = 2;
|
|
|
|
public function __construct(
|
|
private readonly FileSource $fileSource,
|
|
) {}
|
|
|
|
#[Route('/api/share/search', name: 'share_search', methods: ['GET'], priority: 1)]
|
|
#[IsGranted('IS_AUTHENTICATED_FULLY')]
|
|
public function __invoke(Request $request): JsonResponse
|
|
{
|
|
$query = trim((string) $request->query->get('q', ''));
|
|
|
|
if (mb_strlen($query) < self::MIN_QUERY_LENGTH) {
|
|
return new JsonResponse(['query' => $query, 'entries' => []]);
|
|
}
|
|
|
|
try {
|
|
$entries = $this->fileSource->search($query);
|
|
} catch (ShareNotConfiguredException) {
|
|
return new JsonResponse(['error' => 'Share not configured.'], 409);
|
|
} catch (ShareConnectionException) {
|
|
return new JsonResponse(['error' => 'Unable to reach the file share.'], 502);
|
|
}
|
|
|
|
return new JsonResponse([
|
|
'query' => $query,
|
|
'entries' => array_map(static fn (FileEntry $e): array => [
|
|
'name' => $e->name,
|
|
'path' => $e->path,
|
|
'isDir' => $e->isDir,
|
|
'size' => $e->size,
|
|
'modifiedAt' => $e->modifiedAt,
|
|
'mimeType' => $e->mimeType,
|
|
], $entries),
|
|
]);
|
|
}
|
|
}
|