You are here

public function Relation::endpoints in Relation 8

Same name and namespace in other branches
  1. 8.2 src/Entity/Relation.php \Drupal\relation\Entity\Relation::endpoints()

Filters endpoints by entity type.

Suitable for direct usage with entity_load_multiple().

Example:

$endpoints = $relation
  ->endpoints();
$users = entity_load_multiple('user', $endpoints['user']);

Sample return value:

array(
  "node" => array(
    5,
  ),
  "user" => array(
    2,
  ),
);

Return value

array An array where keys are entity type, and values are arrays containing entity IDs of endpoints.

Overrides RelationInterface::endpoints

File

src/Entity/Relation.php, line 116
Contains \Drupal\relation\Entity\Relation.

Class

Relation
Defines relation entity.

Namespace

Drupal\relation\Entity

Code

public function endpoints() {
  $entities = array();
  foreach ($this->endpoints as $endpoint) {
    $entities[$endpoint->entity_type][$endpoint->entity_id] = $endpoint->entity_type;
  }
  return $entities;
}