You are here

public function SiteSettingEntityListBuilder::buildRow in Site Settings and Labels 8

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()

1 call to SiteSettingEntityListBuilder::buildRow()
SiteSettingEntityListBuilder::render in src/SiteSettingEntityListBuilder.php
Builds the entity listing as renderable array for table.html.twig.

File

src/SiteSettingEntityListBuilder.php, line 123

Class

SiteSettingEntityListBuilder
Defines a class to build a listing of Site Setting entities.

Namespace

Drupal\site_settings

Code

public function buildRow(EntityInterface $entity) {

  /* @var $entity \Drupal\site_settings\Entity\SiteSettingEntity */
  $row['name'] = $this->linkGeneration
    ->generate($entity
    ->label(), new Url('entity.site_setting_entity.edit_form', [
    'site_setting_entity' => $entity
      ->id(),
  ]));
  $entity_bundle = $entity
    ->bundle();
  if ($bundle = SiteSettingEntityType::load($entity_bundle)) {
    $row['fieldset'] = $bundle->fieldset;
  }
  else {
    $row['fieldset'] = $this
      ->t('Unknown');
  }

  // Render the value of the field into the listing page.
  $row['value'] = '';
  $fields = $entity
    ->getFields();
  foreach ($fields as $key => $field) {
    if (method_exists(get_class($field), 'getFieldDefinition')) {
      $row['value'] = $this->siteSettingsRender
        ->renderField($field);
    }
  }
  return $row + parent::buildRow($entity);
}