public function RestIncidentStorage::getIncidentsByType in Radioactivity 8.3
Same name and namespace in other branches
- 4.0.x src/RestIncidentStorage.php \Drupal\radioactivity\RestIncidentStorage::getIncidentsByType()
Gets all incidents from the storage per entity type.
Parameters
string $entity_type: Entity type for selection. Default to all entity types.
Return value
\Drupal\radioactivity\IncidentInterface[][] Array of incident objects keyed by entity type (1st) and entity ID (2nd).
Overrides IncidentStorageInterface::getIncidentsByType
File
- src/
RestIncidentStorage.php, line 46
Class
- RestIncidentStorage
- Defines a REST incident storage.
Namespace
Drupal\radioactivityCode
public function getIncidentsByType($entity_type = '') {
$incidents = [];
$stored_incidents = $this
->getIncidents();
foreach ($stored_incidents as $incident) {
$incidents[$incident
->getEntityTypeId()][$incident
->getEntityId()][] = $incident;
}
if (isset($incidents[$entity_type])) {
return [
$entity_type => $incidents[$entity_type],
];
}
return $incidents ?: [
[],
];
}