getContent(), true, 512, JSON_THROW_ON_ERROR); $queryString = $query['search']; } catch (\JsonException $e) { throw $this->createNotFoundException(); } $hotels = $this->hotelDataProvider->getAll(); $data = []; foreach ($hotels as $hotel) { $name = $hotel->getName(); if (1 === preg_match('/'.preg_quote($queryString, '/').'/i', $name)) { $data[] = [ 'value' => $hotel->getBusProId(), 'text' => sprintf('%s (%s)', $name, $hotel->getCode()), ]; } } return $this->json($data); } }