You are here

public function RulesComponentListBuilder::buildRow in Rules 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

src/Controller/RulesComponentListBuilder.php, line 73

Class

RulesComponentListBuilder
Defines a class to build a listing of RulesComponentConfig entities.

Namespace

Drupal\rules\Controller

Code

public function buildRow(EntityInterface $entity) {
  $expression_config = $entity
    ->getExpression()
    ->getConfiguration();
  $definition = $this->expressionManager
    ->getDefinition($expression_config['id']);
  $plugin_type = $definition['label'];

  /** @var \Drupal\rules\Entity\RulesComponentConfig $entity */
  $details = $this
    ->t('Machine name: @name', [
    '@name' => $entity
      ->id(),
  ]);
  if ($entity
    ->hasTags()) {
    $details = $details . '<br />' . $this
      ->t('Tags: @tags', [
      '@tags' => implode(', ', $entity
        ->getTags()),
    ]);
  }
  $row['label']['data-drupal-selector'] = 'rules-table-filter-text-source';
  $row['label']['data'] = [
    '#plain_text' => $entity
      ->label(),
    '#suffix' => '<div class="description">' . $details . '</div>',
  ];
  $row['plugin']['data-drupal-selector'] = 'rules-table-filter-text-source';
  $row['plugin']['data'] = [
    '#plain_text' => $plugin_type,
  ];
  $row['description']['data-drupal-selector'] = 'rules-table-filter-text-source';
  $row['description']['data'] = [
    '#type' => 'processed_text',
    '#text' => $entity
      ->getDescription(),
    '#format' => 'restricted_html',
  ];
  return $row + parent::buildRow($entity);
}