class EntityImportStatusListBuilder in Entity Share 8.3
Provides a listing of Import status entities.
Hierarchy
- class \Drupal\Core\Entity\EntityHandlerBase uses DependencySerializationTrait, StringTranslationTrait
- class \Drupal\Core\Entity\EntityListBuilder implements EntityHandlerInterface, EntityListBuilderInterface uses MessengerTrait, RedirectDestinationTrait
- class \Drupal\entity_share_client\EntityImportStatusListBuilder
- class \Drupal\Core\Entity\EntityListBuilder implements EntityHandlerInterface, EntityListBuilderInterface uses MessengerTrait, RedirectDestinationTrait
Expanded class hierarchy of EntityImportStatusListBuilder
File
- modules/
entity_share_client/ src/ EntityImportStatusListBuilder.php, line 22
Namespace
Drupal\entity_share_clientView source
class EntityImportStatusListBuilder extends EntityListBuilder {
/**
* The format for the import time.
*
* Long format, with seconds.
*/
const IMPORT_DATE_FORMAT = 'F j, Y - H:i:s';
/**
* The date formatter service.
*
* @var \Drupal\Core\Datetime\DateFormatterInterface
*/
protected $dateFormatter;
/**
* The entity type manager.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityTypeManager;
/**
* The entity type manager.
*
* @var \Drupal\Core\Entity\EntityTypeBundleInfoInterface
*/
protected $entityTypeBundleInfo;
/**
* The language manager.
*
* @var \Drupal\Core\Language\LanguageManagerInterface
*/
protected $languageManager;
/**
* Constructs a new UserListBuilder object.
*
* @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
* The entity type definition.
* @param \Drupal\Core\Entity\EntityStorageInterface $storage
* The entity storage class.
* @param \Drupal\Core\Datetime\DateFormatterInterface $date_formatter
* The date formatter service.
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* The entity type manager.
* @param \Drupal\Core\Entity\EntityTypeBundleInfoInterface $entity_type_bundle_info
* The entity type bundle info.
* @param \Drupal\Core\Language\LanguageManagerInterface $language_manager
* The language manager.
*/
public function __construct(EntityTypeInterface $entity_type, EntityStorageInterface $storage, DateFormatterInterface $date_formatter, EntityTypeManagerInterface $entity_type_manager, EntityTypeBundleInfoInterface $entity_type_bundle_info, LanguageManagerInterface $language_manager) {
parent::__construct($entity_type, $storage);
$this->dateFormatter = $date_formatter;
$this->entityTypeManager = $entity_type_manager;
$this->entityTypeBundleInfo = $entity_type_bundle_info;
$this->languageManager = $language_manager;
}
/**
* {@inheritdoc}
*/
public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) {
return new static($entity_type, $container
->get('entity_type.manager')
->getStorage($entity_type
->id()), $container
->get('date.formatter'), $container
->get('entity_type.manager'), $container
->get('entity_type.bundle.info'), $container
->get('language_manager'));
}
/**
* {@inheritdoc}
*/
public function buildHeader() {
$header = [];
$header['id'] = $this
->t('ID');
$header['entity_uuid'] = $this
->t('Entity UUID');
$header['entity_id'] = $this
->t('Entity ID');
$header['langcode'] = $this
->t('Language');
$header['entity_label'] = $this
->t('Link to entity');
$header['entity_type_id'] = $this
->t('Entity type');
$header['entity_bundle'] = $this
->t('Bundle');
$header['remote_website'] = $this
->t('Remote');
$header['channel_id'] = $this
->t('Channel');
$header['last_import'] = $this
->t('Last import');
$header['policy'] = $this
->t('Policy');
return $header + parent::buildHeader();
}
/**
* {@inheritdoc}
*/
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);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DependencySerializationTrait:: |
protected | property | An array of entity type IDs keyed by the property name of their storages. | |
DependencySerializationTrait:: |
protected | property | An array of service IDs keyed by property name used for serialization. | |
DependencySerializationTrait:: |
public | function | 1 | |
DependencySerializationTrait:: |
public | function | 2 | |
EntityHandlerBase:: |
protected | property | The module handler to invoke hooks on. | 2 |
EntityHandlerBase:: |
protected | function | Gets the module handler. | 2 |
EntityHandlerBase:: |
public | function | Sets the module handler for this handler. | |
EntityImportStatusListBuilder:: |
protected | property | The date formatter service. | |
EntityImportStatusListBuilder:: |
protected | property | The entity type manager. | |
EntityImportStatusListBuilder:: |
protected | property | The entity type manager. | |
EntityImportStatusListBuilder:: |
protected | property | The language manager. | |
EntityImportStatusListBuilder:: |
public | function |
Builds the header row for the entity listing. Overrides EntityListBuilder:: |
|
EntityImportStatusListBuilder:: |
public | function |
Builds a row for an entity in the entity listing. Overrides EntityListBuilder:: |
|
EntityImportStatusListBuilder:: |
public static | function |
Instantiates a new instance of this entity handler. Overrides EntityListBuilder:: |
|
EntityImportStatusListBuilder:: |
constant | The format for the import time. | ||
EntityImportStatusListBuilder:: |
public | function |
Constructs a new UserListBuilder object. Overrides EntityListBuilder:: |
|
EntityListBuilder:: |
protected | property | Information about the entity type. | |
EntityListBuilder:: |
protected | property | The entity type ID. | |
EntityListBuilder:: |
protected | property | The number of entities to list per page, or FALSE to list all entities. | 3 |
EntityListBuilder:: |
protected | property | The entity storage class. | 1 |
EntityListBuilder:: |
public | function | Builds a renderable list of operation links for the entity. | 2 |
EntityListBuilder:: |
protected | function | Ensures that a destination is present on the given URL. | |
EntityListBuilder:: |
protected | function | Gets this list's default operations. | 2 |
EntityListBuilder:: |
protected | function | Loads entity IDs using a pager sorted by the entity id. | 4 |
EntityListBuilder:: |
protected | function | Gets the label of an entity. | |
EntityListBuilder:: |
public | function |
Provides an array of information to build a list of operation links. Overrides EntityListBuilderInterface:: |
2 |
EntityListBuilder:: |
public | function |
Gets the entity storage. Overrides EntityListBuilderInterface:: |
|
EntityListBuilder:: |
protected | function | Gets the title of the page. | 1 |
EntityListBuilder:: |
public | function |
Loads entities of this type from storage for listing. Overrides EntityListBuilderInterface:: |
4 |
EntityListBuilder:: |
public | function |
Builds the entity listing as renderable array for table.html.twig. Overrides EntityListBuilderInterface:: |
16 |
MessengerTrait:: |
protected | property | The messenger. | 29 |
MessengerTrait:: |
public | function | Gets the messenger. | 29 |
MessengerTrait:: |
public | function | Sets the messenger. | |
RedirectDestinationTrait:: |
protected | property | The redirect destination service. | 1 |
RedirectDestinationTrait:: |
protected | function | Prepares a 'destination' URL query parameter for use with \Drupal\Core\Url. | |
RedirectDestinationTrait:: |
protected | function | Returns the redirect destination service. | |
RedirectDestinationTrait:: |
public | function | Sets the redirect destination service. | |
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. |