Supposing the list contains paths like /node/2, /user/1, or admin/content, and you need to get the route name for those paths handled by the Views module, you could use code similar to the following one.
use Drupal\Core\Path\PathValidatorInterface;
use Drupal\Core\Url;
function _view_routes(array $paths) {
$view_routes = [];
$path_validator = \Drupal::service('path.validator');
foreach ($paths as $path) {
$view_route = '';
if ($url = $path_validator->getUrlIfValid($path)) {
$route_name = $url->getRouteName();
if (strpos($route_name, 'view.') === 0) {
$view_route = $route_name;
}
}
$view_routes[$path] = $view_route;
}
return $view_routes;
}
PathValidator::getUrlIfValid()
returns a Url
object if the path it gets as argument is valid and accessible from the currently logged-in user. To understand which paths are for pages handled by the Views module, independently from which users have access to that page, the code should be similar to the following one.
use Symfony\Component\Routing\Matcher\RequestMatcherInterface;
function _view_routes(array $paths) {
$view_routes = [];
$router = \Drupal::service('router.no_access_checks');
foreach ($paths as $path) {
try {
$match = $router->match($path);
}
catch (\Exception $e) {
// The path isn't valid or the HTTP method to access the
// path isn't allowed.
$view_routes[$path] = '';
continue;
}
$view_routes[$path] = (strpos($match['_route'], 'view.') === 0 ? $match['_route'] : '');
}
return $view_routes;
}