1 url_alter_test.module | url_alter_test_url_inbound_alter(&$path, $original_path, $path_language) |
Implements hook_url_inbound_alter().
File
- core/
modules/ simpletest/ tests/ url_alter_test.module, line 31 - Module to help test hook_url_inbound_alter() and hook_url_outbound_alter().
Code
function url_alter_test_url_inbound_alter(&$path, $original_path, $path_language) {
if (!request_path() && !empty($_GET['q'])) {
backdrop_set_message("\$_GET['q'] is non-empty with an empty request path.");
}
// Rewrite user/username to user/uid.
if (preg_match('!^user/([^/]+)(/.*)?!', $path, $matches)) {
if ($account = user_load_by_name($matches[1])) {
$matches += array(2 => '');
$path = 'user/' . $account->uid . $matches[2];
}
}
if ($path == 'url-alter-test/bar') {
$path = 'url-alter-test/foo';
}
}