function PathAliasListBuilder::buildRow

Same name in other branches
  1. 8.9.x core/modules/path/src/PathAliasListBuilder.php \Drupal\path\PathAliasListBuilder::buildRow()
  2. 10 core/modules/path/src/PathAliasListBuilder.php \Drupal\path\PathAliasListBuilder::buildRow()
  3. 11.x core/modules/path/src/PathAliasListBuilder.php \Drupal\path\PathAliasListBuilder::buildRow()

Overrides EntityListBuilder::buildRow

File

core/modules/path/src/PathAliasListBuilder.php, line 162

Class

PathAliasListBuilder
Defines a class to build a listing of path_alias entities.

Namespace

Drupal\path

Code

public function buildRow(EntityInterface $entity) {
    
    /** @var \Drupal\Core\Path\Entity\PathAlias $entity */
    $langcode = $entity->language()
        ->getId();
    $alias = $entity->getAlias();
    $path = $entity->getPath();
    $url = Url::fromUserInput($path);
    $row['data']['alias']['data'] = [
        '#type' => 'link',
        '#title' => Unicode::truncate($alias, 50, FALSE, TRUE),
        '#url' => $url->setOption('attributes', [
            'title' => $alias,
        ]),
    ];
    $row['data']['path']['data'] = [
        '#type' => 'link',
        '#title' => Unicode::truncate($path, 50, FALSE, TRUE),
        '#url' => $url->setOption('attributes', [
            'title' => $path,
        ]),
    ];
    if ($this->languageManager
        ->isMultilingual()) {
        $row['data']['language_name'] = $this->languageManager
            ->getLanguageName($langcode);
    }
    $row['data']['operations']['data'] = $this->buildOperations($entity);
    // If the system path maps to a different URL alias, highlight this table
    // row to let the user know of old aliases.
    if ($alias != $this->aliasManager
        ->getAliasByPath($path, $langcode)) {
        $row['class'] = [
            'warning',
        ];
    }
    return $row;
}

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