You are here

function EntityReference_SelectionHandler_Views::validateReferencableEntities in Entity reference 7

Validate that entities can be referenced by this field.

Return value

An array of entity ids that are valid.

Overrides EntityReference_SelectionHandler::validateReferencableEntities

File

plugins/selection/EntityReference_SelectionHandler_Views.class.php, line 155

Class

EntityReference_SelectionHandler_Views
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;
}