public function ContentEntitySourcePluginUi::overviewForm

Builds the overview form for the source entities.

Parameters

array $form: Drupal form array.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

string $type: Entity type.

Return value

array Drupal form array.

Overrides SourcePluginUiBase::overviewForm

File

sources/content/src/ContentEntitySourcePluginUi.php, line 230

Class

ContentEntitySourcePluginUi
Content entity source plugin UI.

Namespace

Drupal\tmgmt_content

Code

public function overviewForm(array $form, FormStateInterface $form_state, $type) {
  $form = parent::overviewForm($form, $form_state, $type);

  // Build a list of allowed search conditions and get their values from the request.
  $entity_type = \Drupal::entityTypeManager()
    ->getDefinition($type);
  $whitelist = array(
    'langcode',
    'target_language',
    'target_status',
  );
  if ($entity_type
    ->hasKey('bundle')) {
    $whitelist[] = $entity_type
      ->getKey('bundle');
  }
  if ($entity_type
    ->hasKey('label')) {
    $whitelist[] = $entity_type
      ->getKey('label');
  }
  $search_property_params = array_filter(\Drupal::request()->query
    ->all());
  $search_property_params = array_intersect_key($search_property_params, array_flip($whitelist));
  $bundles = $this
    ->getTranslatableBundles($type);
  foreach (static::getTranslatableEntities($type, $search_property_params, TRUE) as $entity) {

    // This occurs on user entity type.
    if ($entity
      ->id()) {
      $form['items']['#options'][$entity
        ->id()] = $this
        ->overviewRow($entity, $bundles);
    }
  }
  $form['pager'] = array(
    '#type' => 'pager',
  );
  return $form;
}