You are here

public function TaxonomyHierarchySelection::validateReferenceableEntities in Workbench Access 8

Validates which existing entities can be referenced.

Return value

array An array of valid entity IDs.

Overrides DefaultSelection::validateReferenceableEntities

File

src/Plugin/EntityReferenceSelection/TaxonomyHierarchySelection.php, line 155

Class

TaxonomyHierarchySelection
Provides specific access control for the taxonomy_term entity type.

Namespace

Drupal\workbench_access\Plugin\EntityReferenceSelection

Code

public function validateReferenceableEntities(array $ids) {
  $valid = [];
  if ($allowed = $this
    ->getReferenceableEntities()) {
    foreach ($ids as $id) {
      foreach ($allowed as $parent => $child) {
        if (isset($child[$id])) {
          $valid[$id] = $id;
          break;
        }
      }
    }
  }
  return $valid;
}