public function PathAliasListBuilder::buildRow in Drupal 8
Same name and namespace in other branches
- 9 core/modules/path/src/PathAliasListBuilder.php \Drupal\path\PathAliasListBuilder::buildRow()
Builds a row for an entity in the entity listing.
Parameters
\Drupal\Core\Entity\EntityInterface $entity: The entity for this row of the list.
Return value
array A render array structure of fields for this entity.
Overrides EntityListBuilder::buildRow
See also
\Drupal\Core\Entity\EntityListBuilder::render()
File
- core/
modules/ path/ src/ PathAliasListBuilder.php, line 162
Class
- PathAliasListBuilder
- Defines a class to build a listing of path_alias entities.
Namespace
Drupal\pathCode
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;
}