public function EntityImportStatusListBuilder::buildRow in Entity Share 8.3
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
- modules/
entity_share_client/ src/ EntityImportStatusListBuilder.php, line 126
Class
- EntityImportStatusListBuilder
- Provides a listing of Import status entities.
Namespace
Drupal\entity_share_clientCode
public function buildRow(EntityInterface $entity) {
$row = [];
$row['id'] = $entity
->id();
// Load the imported entity.
$imported_entity_storage = $this->entityTypeManager
->getStorage($entity->entity_type_id->value);
$imported_entity = $imported_entity_storage
->load($entity->entity_id->value);
// Basic keys of imported entity.
$row['entity_uuid'] = $entity->entity_uuid->value;
$row['entity_id'] = $entity->entity_id->value;
$row['langcode'] = $this->languageManager
->getLanguage($entity->langcode->value)
->getName();
// Label and link to entity should respect the language.
/** @var \Drupal\Core\Entity\ContentEntityInterface $imported_entity_translation */
$imported_entity_translation = $imported_entity
->getTranslation($entity->langcode->value);
try {
$row['entity_label'] = $imported_entity_translation
->toLink($imported_entity_translation
->label());
} catch (UndefinedLinkTemplateException $exception) {
$row['entity_label'] = $imported_entity_translation
->label();
}
// Label of entity type.
$row['entity_type_id'] = $imported_entity_storage
->getEntityType()
->getLabel();
// Imported entity's bundle.
$bundle_info = $this->entityTypeBundleInfo
->getBundleInfo($entity->entity_type_id->value);
$row['entity_bundle'] = $bundle_info[$entity->entity_bundle->value]['label'] ?? $entity->entity_bundle->value;
// Remote website.
$remote = $this->entityTypeManager
->getStorage('remote')
->load($entity->remote_website->value);
$row['remote_website'] = $remote
->label();
// Machine name of the import channel.
$row['channel_id'] = $entity->channel_id->value;
// Last import time.
$row['last_import'] = $this->dateFormatter
->format($entity
->getLastImport(), 'custom', self::IMPORT_DATE_FORMAT);
// Label of the import policy (or raw value if illegal).
$available_policies = EntityImportStatus::getAvailablePolicies();
$row['policy'] = $available_policies[$entity
->getPolicy()] ?? $entity
->getPolicy();
return $row + parent::buildRow($entity);
}