You are here

private function BusinessRulesViewsSelection::getValidIds in Business Rules 8

Same name and namespace in other branches
  1. 2.x src/Plugin/EntityReferenceSelection/BusinessRulesViewsSelection.php \Drupal\business_rules\Plugin\EntityReferenceSelection\BusinessRulesViewsSelection::getValidIds()

Return valid ids for validation.

Parameters

string $parent_field_value: The parent field value.

Return value

array Array with valid ids.

1 call to BusinessRulesViewsSelection::getValidIds()
BusinessRulesViewsSelection::validateReferenceableEntities in src/Plugin/EntityReferenceSelection/BusinessRulesViewsSelection.php
Validates which existing entities can be referenced.

File

src/Plugin/EntityReferenceSelection/BusinessRulesViewsSelection.php, line 497

Class

BusinessRulesViewsSelection
Plugin override of the 'selection' entity_reference.

Namespace

Drupal\business_rules\Plugin\EntityReferenceSelection

Code

private function getValidIds($parent_field_value) {
  $handler_settings = $this
    ->getHandlerSettings();
  $display_name = $handler_settings['business_rules_view']['display_name'];
  $arguments = $handler_settings['business_rules_view']['arguments'];
  $arguments = !empty($parent_field_value) ? [
    $parent_field_value,
  ] + $arguments : $arguments;
  $result = [];
  if ($this
    ->initializeView(NULL, 'CONTAINS', 0)) {

    // Get the results.
    $result = $this->view
      ->executeDisplay($display_name, $arguments);
  }
  $return = [];
  if ($result) {
    foreach ($this->view->result as $row) {
      $entity = $row->_entity;
      $return[] = $entity
        ->id();
    }
  }
  return $return;
}