You are here

public function GroupTypeController::buildRow in Group 2.0.x

Same name and namespace in other branches
  1. 8 src/Entity/Controller/GroupTypeController.php \Drupal\group\Entity\Controller\GroupTypeController::buildRow()

Builds a row for a group relation plugin.

Parameters

\Drupal\group\Plugin\Group\Relation\GroupRelationInterface $plugin: The group relation plugin to build operation links for.

bool $is_installed: Whether the plugin is installed.

Return value

array A render array to use as a table row.

1 call to GroupTypeController::buildRow()
GroupTypeController::content in src/Entity/Controller/GroupTypeController.php
Builds an admin interface to manage the group type's group content plugins.

File

src/Entity/Controller/GroupTypeController.php, line 154

Class

GroupTypeController
Provides the user permissions administration form for a specific group type.

Namespace

Drupal\group\Entity\Controller

Code

public function buildRow(GroupRelationInterface $plugin, $is_installed) {
  $status = $is_installed ? $this
    ->t('Installed') : $this
    ->t('Available');
  $install_type = $this
    ->t('Manual');
  if ($plugin
    ->isEnforced()) {
    $install_type = $this
      ->t('Enforced');
  }
  elseif ($plugin
    ->isCodeOnly()) {
    $install_type = $this
      ->t('Code-only');
  }
  $row = [
    'info' => [
      '#type' => 'inline_template',
      '#template' => '<div class="description"><span class="label">{{ label }}</span>{% if description %}<br/>{{ description }}{% endif %}</div>',
      '#context' => [
        'label' => $plugin
          ->getLabel(),
      ],
    ],
    'provider' => [
      '#markup' => $this->moduleHandler
        ->getName($plugin
        ->getProvider()),
    ],
    'entity_type_id' => [
      '#markup' => $this->entityTypeManager
        ->getDefinition($plugin
        ->getEntityTypeId())
        ->getLabel(),
    ],
    'status' => [
      '#markup' => $status,
    ],
    'install_type' => [
      '#markup' => $install_type,
    ],
    'operations' => $this
      ->buildOperations($plugin, $is_installed),
  ];

  // Show the group relation description if toggled on.
  if (!system_admin_compact_mode()) {
    $row['info']['#context']['description'] = $plugin
      ->getDescription();
  }
  return $row;
}