You are here

public function GroupTypeController::content in Group 2.0.x

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

Builds an admin interface to manage the group type's group content plugins.

Parameters

\Drupal\group\Entity\GroupTypeInterface $group_type: The group type to build an interface for.

Return value

array The render array for the page.

1 string reference to 'GroupTypeController::content'
group.routing.yml in ./group.routing.yml
group.routing.yml

File

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

Class

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

Namespace

Drupal\group\Entity\Controller

Code

public function content(GroupTypeInterface $group_type) {
  $this->groupType = $group_type;
  $rows['installed'] = $rows['available'] = [];
  $installed_ids = $this->pluginManager
    ->getInstalledIds($group_type);
  foreach ($this->pluginManager
    ->getAll() as $plugin_id => $plugin) {
    $is_installed = FALSE;

    // If the plugin is installed on the group type, use that one instead of
    // an 'empty' version so that we may use methods on it which expect to
    // have a group type configured.
    if (in_array($plugin_id, $installed_ids)) {
      $plugin = $this->groupType
        ->getContentPlugin($plugin_id);
      $is_installed = TRUE;
    }
    $status = $is_installed ? 'installed' : 'available';
    $rows[$status][$plugin_id] = $this
      ->buildRow($plugin, $is_installed);
  }
  $page['information'] = [
    '#type' => 'fieldset',
    '#title' => $this
      ->t('Information about content plugins'),
  ];
  $page['information']['intro']['#markup'] = $this
    ->t('<p>In order to be able to add entities as content to groups of this group type, a so-called content plugin needs to be installed. This plugin informs the Group module on how the entity type can be added to a group, what rules apply and whether it should control access over said entity type. When a plugin is installed, you should check out its configuration form to see what options are available to further customize the plugin behavior.</p>');
  $page['information']['fields']['#markup'] = $this
    ->t('<p>Should you choose to show the relationship entities that track which entity belongs to which group or should the module that provided the module enforce this, you can control which fields are available on that relation entity and how they are presented in the front-end.</p>');
  $page['information']['install_types'] = [
    '#theme' => 'item_list',
    '#items' => [
      $this
        ->t('<strong>Manual</strong> content plugins can be (un)installed freely by the user'),
      $this
        ->t('<strong>Code-only</strong> content plugins can only be (un)installed through code, this is often done when certain conditions are met in the module that provided the plugin'),
      $this
        ->t('<strong>Enforced</strong> content plugins are always enabled and cannot be uninstalled'),
    ],
    '#prefix' => $this
      ->t('<p>The following installation types are available:</p>'),
  ];
  $page['system_compact_link'] = [
    '#id' => FALSE,
    '#type' => 'system_compact_link',
  ];
  $page['content'] = [
    '#type' => 'table',
    '#header' => [
      'info' => $this
        ->t('Plugin information'),
      'provider' => $this
        ->t('Provided by'),
      'entity_type_id' => $this
        ->t('Applies to'),
      'status' => $this
        ->t('Status'),
      'install_type' => $this
        ->t('Installation type'),
      'operations' => $this
        ->t('Operations'),
    ],
  ];
  $page['content'] += $rows['installed'];
  $page['content'] += $rows['available'];
  return $page;
}