public function RenameAdminPathsProcessor::processOutbound in Rename Admin Paths 8
Implements Drupal\Core\PathProcessor\OutboundPathProcessorInterface::processOutbound().
Overrides OutboundPathProcessorInterface::processOutbound
File
- src/
RenameAdminPathsProcessor.php, line 55
Class
- RenameAdminPathsProcessor
- Path processor for url_alter_test.
Namespace
Drupal\rename_admin_pathsCode
public function processOutbound($path, &$options = [], Request $request = NULL, BubbleableMetadata $bubbleable_metadata = NULL) {
$config = \Drupal::config('rename_admin_paths.settings');
// Admin path.
if ($request && $config
->get('admin_path')) {
$admin_path_value = $config
->get('admin_path_value');
// Replace admin in path.
if (preg_match('|^/admin(?![^/])(.*)|', $path, $matches)) {
$path = '/' . urlencode($admin_path_value) . $matches[1];
}
}
// User path.
if ($config
->get('user_path')) {
$user_path_value = $config
->get('user_path_value');
// Replace user in path.
if (preg_match('|^/user(?![^/])(.*)|', $path, $matches)) {
$path = '/' . urlencode($user_path_value) . $matches[1];
}
}
return $path;
}