You are here

public function WebformContentCreatorListBuilder::buildRow in Webform Content Creator 2.x

Same name and namespace in other branches
  1. 8 src/Controller/WebformContentCreatorListBuilder.php \Drupal\webform_content_creator\Controller\WebformContentCreatorListBuilder::buildRow()
  2. 3.x src/Controller/WebformContentCreatorListBuilder.php \Drupal\webform_content_creator\Controller\WebformContentCreatorListBuilder::buildRow()

Constructs the table rows.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: Webform content creator entity.

Return value

\Drupal\Core\Entity\EntityListBuilder A render array structure of fields for this entity.

Overrides EntityListBuilder::buildRow

File

src/Controller/WebformContentCreatorListBuilder.php, line 46

Class

WebformContentCreatorListBuilder
Provides a list of Webform Content Creator entities.

Namespace

Drupal\webform_content_creator\Controller

Code

public function buildRow(EntityInterface $entity) {
  $webform = \Drupal::entityTypeManager()
    ->getStorage(self::WEBFORM)
    ->load($entity
    ->getWebform());
  $entity_type_id = $entity
    ->getEntityTypeValue();
  $entity_type = \Drupal::entityTypeManager()
    ->getDefinitions()[$entity_type_id];
  $bundle = \Drupal::service('entity_type.bundle.info')
    ->getBundleInfo($entity_type_id)[$entity
    ->getBundleValue()];
  if (!empty($webform) && !empty($entity_type) && !empty($bundle)) {
    $row[self::TITLE] = $entity
      ->get('title') . ' (' . $entity
      ->id() . ')';
    $row[self::WEBFORM] = $webform
      ->label() . ' (' . $entity
      ->getWebform() . ')';
    $row[self::ENTITY_TYPE] = $entity_type
      ->getLabel() . ' (' . $entity
      ->getEntityTypeValue() . ')';
    $row[self::BUNDLE] = $bundle['label'] . ' (' . $entity
      ->getBundleValue() . ')';
    return $row + parent::buildRow($entity);
  }
  return parent::buildRow($entity);
}