function RulesComponentListBuilder::buildRow

Overrides EntityListBuilder::buildRow

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);
}