protected function TeamMembershipManager::dispatchEvent in Apigee Edge 8
Helper to dispatch event.
Parameters
string $event: The event name.
string $team: The team id.
array $developers: An array of developers.
Throws
\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
\Drupal\Component\Plugin\Exception\PluginNotFoundException
2 calls to TeamMembershipManager::dispatchEvent()
- TeamMembershipManager::addMembers in modules/
apigee_edge_actions/ src/ TeamMembershipManager.php - Adds members to a team.
- TeamMembershipManager::removeMembers in modules/
apigee_edge_actions/ src/ TeamMembershipManager.php - Removes members from a team.
File
- modules/
apigee_edge_actions/ src/ TeamMembershipManager.php, line 171
Class
- TeamMembershipManager
- Decorates the apigee_edge_teams.team_membership_manager service.
Namespace
Drupal\apigee_edge_actionsCode
protected function dispatchEvent(string $event, string $team, array $developers) {
$team = $this->entityTypeManager
->getStorage('team')
->load($team);
$users_by_mail = array_reduce($this->entityTypeManager
->getStorage('user')
->loadByProperties([
'mail' => $developers,
]), function (array $carry, UserInterface $user) {
$carry[$user
->getEmail()] = $user;
return $carry;
}, []);
// Dispatch an event for each developer.
foreach ($developers as $developer) {
$this->eventDispatcher
->dispatch($event, new EdgeEntityEventEdge($team, [
'team' => $team,
'member' => $users_by_mail[$developer],
]));
}
}