3 namespace Drupal\url_alter_test;
5 use Drupal\Core\PathProcessor\InboundPathProcessorInterface;
6 use Symfony\Component\HttpFoundation\Request;
9 * Path processor for url_alter_test.
11 class PathProcessor implements InboundPathProcessorInterface {
16 public function processInbound($path, Request $request) {
17 if (preg_match('!^/user/([^/]+)(/.*)?!', $path, $matches)) {
18 if ($account = user_load_by_name($matches[1])) {
19 $matches += [2 => ''];
20 $path = '/user/' . $account->id() . $matches[2];
24 // Rewrite community/ to forum/.
25 $path = preg_replace('@^/community(.*)@', '/forum$1', $path);
27 if ($path == '/url-alter-test/bar') {
28 $path = '/url-alter-test/foo';