1 EntityReferenceSelectionHandlerViews.inc EntityReferenceSelectionHandlerViews::validateReferencableEntities(array $ids)

Validate that entities can be referenced by this field.

Return value

An array of entity ids that are valid.:

Overrides EntityReferenceSelectionHandlerInterface::validateReferencableEntities

File

core/modules/entityreference/plugins/selection/EntityReferenceSelectionHandlerViews.inc, line 157

Class

EntityReferenceSelectionHandlerViews
Entity handler for Views.

Code

function validateReferencableEntities(array $ids) {
  $display_name = $this->field['settings']['handler_settings']['view']['display_name'];
  $args = $this->handleArgs($this->field['settings']['handler_settings']['view']['args']);
  $result = array();
  if ($this->initializeView(NULL, 'CONTAINS', 0, $ids)) {
    // Get the results.
    $entities = $this->view->execute_display($display_name, $args);
    if (!empty($entities)) {
      $result = array_keys($entities);
    }
  }
  return $result;
}