You are here

private function EntityconnectController::fixTargetId in Entity connect 8.2

Makes sure our target id's are correct.

Parameters

array|int $target_id: The target entity id.

Return value

array|int The fixed target_id.

1 call to EntityconnectController::fixTargetId()
EntityconnectController::edit in src/Controller/EntityconnectController.php
Page callback: Redirect to edit form.

File

src/Controller/EntityconnectController.php, line 384

Class

EntityconnectController
Returns responses for Entityconnect module routes.

Namespace

Drupal\entityconnect\Controller

Code

private function fixTargetId($target_id) {
  $array_target_id = is_array($target_id) ? $target_id : [
    $target_id,
  ];
  foreach ($array_target_id as $key => $value) {
    if (!is_numeric($value) && is_string($value)) {
      if ($value = EntityAutocomplete::extractEntityIdFromAutocompleteInput($value)) {
        $array_target_id[$key] = $value;
      }
    }
  }
  return count($array_target_id) == 1 ? $array_target_id[0] : $array_target_id;
}