function UrlGeneratorTest::aliasManagerCallback

Same name and namespace in other branches
  1. 8.9.x core/tests/Drupal/Tests/Core/Routing/UrlGeneratorTest.php \Drupal\Tests\Core\Routing\UrlGeneratorTest::aliasManagerCallback()
  2. 10 core/tests/Drupal/Tests/Core/Routing/UrlGeneratorTest.php \Drupal\Tests\Core\Routing\UrlGeneratorTest::aliasManagerCallback()
  3. 11.x core/tests/Drupal/Tests/Core/Routing/UrlGeneratorTest.php \Drupal\Tests\Core\Routing\UrlGeneratorTest::aliasManagerCallback()

Return value callback for getAliasByPath() on the mock alias manager.

Ensures that by default the call to getAliasByPath() will return the first argument that was passed in. We special-case the paths for which we wish it to return an actual alias.

Return value

string

File

core/tests/Drupal/Tests/Core/Routing/UrlGeneratorTest.php, line 186

Class

UrlGeneratorTest
Confirm that the UrlGenerator is functioning properly.

Namespace

Drupal\Tests\Core\Routing

Code

public function aliasManagerCallback() {
    $args = func_get_args();
    switch ($args[0]) {
        case '/test/one':
            return '/hello/world';
        case '/test/two/5':
            return '/goodbye/cruel/world';
        case '/<front>':
            return '/';
        default:
            return $args[0];
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.