we've wanted to implement a policy to consider some URLs as whitelist, I've provided a config form to admin to enter whitelist Urls, separated by newline, it must support *
( wildcard).
sample urls are
/user/*/edit
/coming-soon
and my implementation
$config = $config_factory->get('mint_coming_soon.softlaunchconfigadmin');
$white_route_list = $config->get('white_path_list');
$white_route_list = $white_route_list ? preg_split("/\\r\\n|\\r|\\n/", $white_route_list) : NULL;
$is_white_route = FALSE;
foreach ($white_route_list as $route) {
$route_name = $this->pathValidator->getUrlIfValid($route);
$route_name = $route_name ? $route_name->getRouteName() : NULL;
drupal_set_message($route_name);
$current_route_name = \Drupal::routeMatch()->getRouteName();
if ($current_route_name == $route_name) {
$is_white_route = TRUE;
break;
}
}
$this->pathValidator->getUrlIfValid
doesn't work on URLs with the wildcard, my question is how can I get the route name of Url which contains a wildcard?
Notice: wildcard in this question is particularly *
.