public function ConnectionService::getConnectionEntityTypes in RedHen CRM 8
Filters entity list to bundle definitions for entities w/ connection types.
Parameters
EntityTypeInterface[] $entity_types: The master entity type list filter.
Return value
ConfigEntityTypeInterface[] An array of only the config entities we want to modify.
Overrides ConnectionServiceInterface::getConnectionEntityTypes
File
- modules/
redhen_connection/ src/ ConnectionService.php, line 49
Class
- ConnectionService
- Provides an interface for getting connections between entities.
Namespace
Drupal\redhen_connectionCode
public function getConnectionEntityTypes(array $entity_types) {
$all_connection_types = [];
foreach ($entity_types as $entity_type => $type) {
$query = $this->entityTypeManager
->getStorage('redhen_connection_type')
->getQuery();
$or_group = $query
->orConditionGroup();
$or_group
->condition('endpoints.1.entity_type', $entity_type);
$or_group
->condition('endpoints.2.entity_type', $entity_type);
$query
->condition($or_group);
$results = $query
->execute();
if (!empty($results)) {
$connection_types = ConnectionType::loadMultiple($results);
$all_connection_types = array_merge($all_connection_types, $connection_types);
}
}
$connected_entities = [];
foreach ($all_connection_types as $connection_type_id => $connection_type) {
$endpoint_1 = $connection_type
->get('endpoints')[1]['entity_type'];
$endpoint_2 = $connection_type
->get('endpoints')[2]['entity_type'];
$connected_entities[$connection_type_id]['endpoint_1'][$endpoint_1] = $entity_types[$endpoint_1];
$connected_entities[$connection_type_id]['endpoint_2'][$endpoint_2] = $entity_types[$endpoint_2];
}
return $connected_entities;
}