You are here

public function GroupContentToEntityBase::buildOptionsForm in Group 8

Same name and namespace in other branches
  1. 2.0.x src/Plugin/views/relationship/GroupContentToEntityBase.php \Drupal\group\Plugin\views\relationship\GroupContentToEntityBase::buildOptionsForm()

Provide a form to edit options for this plugin.

Overrides RelationshipPluginBase::buildOptionsForm

File

src/Plugin/views/relationship/GroupContentToEntityBase.php, line 91

Class

GroupContentToEntityBase
A relationship handler base for group content entity references.

Namespace

Drupal\group\Plugin\views\relationship

Code

public function buildOptionsForm(&$form, FormStateInterface $form_state) {
  parent::buildOptionsForm($form, $form_state);

  // Retrieve all of the plugins that can serve this entity type.
  $options = [];
  foreach ($this->pluginManager
    ->getAll() as $plugin_id => $plugin) {

    /** @var \Drupal\group\Plugin\GroupContentEnablerInterface $plugin */
    if ($plugin
      ->getEntityTypeId() === $this
      ->getTargetEntityType()) {
      $options[$plugin_id] = $plugin
        ->getLabel();
    }
  }
  $form['group_content_plugins'] = [
    '#type' => 'checkboxes',
    '#title' => $this
      ->t('Filter by plugin'),
    '#description' => $this
      ->t('Refine the result by plugin. Leave empty to select all plugins, including those that could be added after this relationship was configured.'),
    '#options' => $options,
    '#weight' => -2,
    '#default_value' => $this->options['group_content_plugins'],
  ];
}