You are here

public function WebformEntityReferenceTrait::getRelatedTypes in Webform 8.5

Same name and namespace in other branches
  1. 6.x src/Plugin/WebformElement/WebformEntityReferenceTrait.php \Drupal\webform\Plugin\WebformElement\WebformEntityReferenceTrait::getRelatedTypes()
1 method overrides WebformEntityReferenceTrait::getRelatedTypes()
WebformTermReferenceTrait::getRelatedTypes in src/Plugin/WebformElement/WebformTermReferenceTrait.php

File

src/Plugin/WebformElement/WebformEntityReferenceTrait.php, line 26

Class

WebformEntityReferenceTrait
Provides an 'entity_reference' trait.

Namespace

Drupal\webform\Plugin\WebformElement

Code

public function getRelatedTypes(array $element) {
  $types = [];
  $plugin_id = $this
    ->getPluginId();
  $elements = $this->elementManager
    ->getInstances();
  foreach ($elements as $element_name => $element_instance) {

    // Skip self.
    if ($plugin_id === $element_instance
      ->getPluginId()) {
      continue;
    }
    if ($element_instance instanceof WebformElementEntityReferenceInterface) {
      $types[$element_name] = $element_instance
        ->getPluginLabel();
    }
  }
  asort($types);
  return $types;
}