function EntityDebugController::pathAliases

Return definitions for any related path aliases.

Parameters

\Drupal\Core\Routing\RouteMatchInterface $route_match: A RouteMatch object.

Return value

array Array of page elements to render.

File

src/Controller/EntityDebugController.php, line 159

Class

EntityDebugController
Controller for devel entity debug.

Namespace

Drupal\devel\Controller

Code

public function pathAliases(RouteMatchInterface $route_match) : array {
    $entity = $this->getEntityFromRouteMatch($route_match);
    if ($entity === NULL) {
        return [];
    }
    $path = sprintf('/%s/%s', $entity->getEntityTypeId(), $entity->id());
    $aliases = $this->aliasStorage
        ->loadByProperties([
        'path' => $path,
    ]);
    $aliasCount = count($aliases);
    if ($aliasCount > 0) {
        $message = $this->translationManager
            ->formatPlural($aliasCount, 'Found 1 alias with path "@path."', 'Found @count aliases with path "@path".', [
            '@path' => $path,
        ]);
    }
    else {
        $message = $this->t('Found no aliases with path "@path".', [
            '@path' => $path,
        ]);
    }
    $build['header'] = [
        '#type' => 'html_tag',
        '#tag' => 'p',
        '#value' => $message,
    ];
    // Add alias dump to the response.
    $build['aliases'] = [];
    foreach ($aliases as $alias) {
        $build['aliases'][] = $this->dumper
            ->exportAsRenderable($alias);
    }
    return $build;
}