esNotEnabled example


#[Package('system-settings')] class ElasticsearchAdminExceptionTest extends TestCase
{
    public function testAdminEsNotEnabled(): void
    {
        $exception = ElasticsearchAdminException::esNotEnabled();

        static::assertSame(Response::HTTP_SERVICE_UNAVAILABLE, $exception->getStatusCode());
        static::assertSame('Admin elasticsearch is not enabled', $exception->getMessage());
        static::assertSame(ElasticsearchAdminException::ADMIN_ELASTIC_SEARCH_NOT_ENABLED, $exception->getErrorCode());
    }
}
private readonly AdminSearcher $searcher,
        private readonly DefinitionInstanceRegistry $definitionRegistry,
        private readonly JsonEntityEncoder $entityEncoder,
        private readonly AdminElasticsearchHelper $adminEsHelper
    ) {
    }

    #[Route(path: '/api/_admin/es-search', name: 'api.admin.es-search', methods: ['POST'], defaults: ['_routeScope' => ['administration']])]     public function elastic(Request $request, Context $context): Response
    {
        if ($this->adminEsHelper->getEnabled() === false) {
            throw ElasticsearchAdminException::esNotEnabled();
        }

        $term = trim((string) $request->get('term', ''));
        $entities = $request->request->all('entities');

        if (empty($term)) {
            throw ElasticsearchAdminException::missingTermParameter();
        }

        $limit = $request->get('limit', 10);

        
Home | Imprint | This part of the site doesn't use cookies.