get(EntityRepository::class)->createRepositoryQuery( $this->getRepositoryQuery(), $context->getSearch(), $context->getEntity(), FieldCollection::new([]), FilterCollection::new() ); if ($this->isInstanceOf(StatusInterface::class)) { $repositoryQuery->filterIsOnlineAndOffline(); } if ($this->isInstanceOf(FilterSectionInterface::class)) { $repositoryQuery->filterBySection($this->getSectionCurrentDefault()); } if ($this->isInstanceOf(FilterMerchantInterface::class)) { $repositoryQuery->filterByMerchant($this->getMerchantCurrent()); } $autocompleteContext = $context->getRequest()->get(AssociationField::PARAM_AUTOCOMPLETE_CONTEXT); /** @var CrudControllerInterface $controller */ $controller = $this->get(ControllerFactory::class)->getCrudControllerInstance( $autocompleteContext[EA::CRUD_CONTROLLER_FQCN], ActionDefinition::INDEX, $context->getRequest() ); /** @var FieldDto $field */ $field = FieldCollection::new( $controller->configureFields($autocompleteContext['originatingPage']) )->getByProperty($autocompleteContext['propertyName']); $filterManager = $this->get(FilterManager::class); $filteredValue = ['value' => $context->getRequest()->query->get('q')]; $filterManager->applyFilter($repositoryQuery, $field, $filteredValue); $repositoryQuery->select('.' . $autocompleteContext['propertyName']); //dump($repositoryQuery->getQueryBuilder()->getQuery()->getDQL()); $responses = array(); foreach ($repositoryQuery->find() as $result) { $responses[] = array_values($result)[0]; } return JsonResponse::fromJsonString(json_encode($responses)); } }