You are here

public function EntityReference_SelectionHandler_DDF::validateReferencableEntities in Dynamic dependent fields 7

Validate that entities can be referenced by this field.

Return value

An array of entity ids that are valid.

Overrides EntityReference_SelectionHandler_Views::validateReferencableEntities

File

modules/ddf_entityreference/plugins/selection/EntityReference_SelectionHandler_DDF.class.php, line 110

Class

EntityReference_SelectionHandler_DDF
Entity handler for Views.

Code

public function validateReferencableEntities(array $ids) {
  $display_name = $this->field['settings']['handler_settings']['view']['display_name'];
  $args = $this
    ->handleArgs($this->field['settings']['handler_settings']['view']['args']);
  $args = $this
    ->handleDynamicArgs($args);
  $result = array();
  if ($this
    ->initializeView(NULL, 'CONTAINS', 0, $ids)) {

    // Get the results.
    $entities = $this->view
      ->execute_display($display_name, $args);
    if (is_null($entities)) {
      $entities = array();
    }
    $result = array_keys($entities);
  }
  return $result;
}