public function FieldStorageConfigListBuilder::buildRow in Drupal 9
Same name and namespace in other branches
- 8 core/modules/field_ui/src/FieldStorageConfigListBuilder.php \Drupal\field_ui\FieldStorageConfigListBuilder::buildRow()
- 10 core/modules/field_ui/src/FieldStorageConfigListBuilder.php \Drupal\field_ui\FieldStorageConfigListBuilder::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/ field_ui/ src/ FieldStorageConfigListBuilder.php, line 101
Class
- FieldStorageConfigListBuilder
- Defines a class to build a listing of fields.
Namespace
Drupal\field_uiCode
public function buildRow(EntityInterface $field_storage) {
if ($field_storage
->isLocked()) {
$row['class'] = [
'menu-disabled',
];
$row['data']['id'] = $this
->t('@field_name (Locked)', [
'@field_name' => $field_storage
->getName(),
]);
}
else {
$row['data']['id'] = $field_storage
->getName();
}
$entity_type_id = $field_storage
->getTargetEntityTypeId();
// Adding the entity type.
$row['data']['entity_type'] = $entity_type_id;
$field_type = $this->fieldTypes[$field_storage
->getType()];
$row['data']['type'] = $this
->t('@type (module: @module)', [
'@type' => $field_type['label'],
'@module' => $field_type['provider'],
]);
$usage = [];
foreach ($field_storage
->getBundles() as $bundle) {
if ($route_info = FieldUI::getOverviewRouteInfo($entity_type_id, $bundle)) {
$usage[] = Link::fromTextAndUrl($this->bundles[$entity_type_id][$bundle]['label'], $route_info)
->toRenderable();
}
else {
$usage[] = $this->bundles[$entity_type_id][$bundle]['label'];
}
}
$row['data']['usage']['data'] = [
'#theme' => 'item_list',
'#items' => $usage,
'#context' => [
'list_style' => 'comma-list',
],
];
return $row;
}