You are here

public function SynonymsEntityAutocomplete::getInfo in Synonyms 8

Returns the element properties for this element.

Return value

array An array of element properties. See \Drupal\Core\Render\ElementInfoManagerInterface::getInfo() for documentation of the standard properties of all elements, and the return value format.

Overrides Textfield::getInfo

File

src/Element/SynonymsEntityAutocomplete.php, line 21

Class

SynonymsEntityAutocomplete
Form element for synonyms-friendly entity autocomplete.

Namespace

Drupal\synonyms\Element

Code

public function getInfo() {
  $info = parent::getInfo();

  // Target entity type for suggestions.
  $info['#target_type'] = NULL;

  // String or array of allowed target bundles. If omitted, all bundles will
  // be included in autocomplete suggestions.
  $info['#target_bundles'] = NULL;

  // Default maximum amount of provided suggestions.
  $info['#suggestion_size'] = 10;

  // Whether to suggest same entity at most once (in the case, when more than
  // 1 synonym triggers inclusion of that entity).
  $info['#suggest_only_unique'] = FALSE;

  // Operator to match keyword. Allowed values are:
  // - CONTAINS
  // - STARTS_WITH.
  $info['#match'] = 'CONTAINS';
  array_unshift($info['#process'], [
    get_class($this),
    'elementSynonymsEntityAutocomplete',
  ]);
  $info['#element_validate'][] = [
    get_class($this),
    'validateEntityAutocomplete',
  ];
  return $info;
}