public function TourUIController::getRoutes in Tour UI 8
Build list of route and path pattern.
Parameters
\Symfony\Component\HttpFoundation\Request $request:
Return value
\Symfony\Component\HttpFoundation\JsonResponse
1 string reference to 'TourUIController::getRoutes'
File
- src/
Controller/ TourUIController.php, line 87
Class
- TourUIController
- Tour UI Controller.
Namespace
Drupal\tour_ui\ControllerCode
public function getRoutes(Request $request) {
$matches = [];
$part = $request->query
->get('q');
if ($part && strlen($part) > 3) {
$list = [];
$result = $this->database
->query('SELECT * from {router}');
foreach ($result as $row) {
$list[$row->name] = $row->name . ' (' . $row->pattern_outline . ')';
}
asort($list);
$matches[] = $part;
$part = preg_quote($part, '/');
foreach ($list as $route => $data) {
if (preg_match("/{$part}/", $data)) {
$matches[] = $data;
}
}
}
return new JsonResponse($matches);
}