protected function TeamStorage::doDelete in Apigee Edge 8
Performs storage-specific entity deletion.
Parameters
\Drupal\Core\Entity\EntityInterface[] $entities: An array of entity objects to delete.
Overrides EdgeEntityStorageBase::doDelete
File
- modules/
apigee_edge_teams/ src/ Entity/ Storage/ TeamStorage.php, line 189
Class
- TeamStorage
- Entity storage implementation for teams.
Namespace
Drupal\apigee_edge_teams\Entity\StorageCode
protected function doDelete($entities) {
parent::doDelete($entities);
/** @var \Drupal\apigee_edge_teams\Entity\Storage\TeamMemberRoleStorageInterface $team_member_role_storage */
$team_member_role_storage = $this->entityTypeManager
->getStorage('team_member_role');
/** @var \Drupal\apigee_edge_teams\Entity\TeamMemberRoleInterface[] $dev_roles_by_teams */
$dev_roles_by_teams = $team_member_role_storage
->loadByProperties([
'team' => array_keys($entities),
]);
// When a team gets deleted all team member roles related to the team
// should be deleted from the database.
foreach ($dev_roles_by_teams as $role) {
try {
$role
->delete();
} catch (\Exception $exception) {
$context = [
'%team' => "{$role->getTeam()->label()} ({$role->getTeam()->id()})",
'%developer' => $role
->getDeveloper()
->getEmail(),
];
$context += Error::decodeException($exception);
$this->logger
->critical("Integrity check: Failed to remove %developer team member's role(s) from %team team when team got deleted. @message %function (line %line of %file). <pre>@backtrace_string</pre>", $context);
}
}
}