contactsIntegration = $ci; $this->groupsIntegration = $gi; $this->addressCollector = $ac; } public function findMatches(string $userId, string $term): array { $recipientsFromContacts = $this->contactsIntegration->getMatchingRecipient($userId, $term); $recipientGroups = $this->groupsIntegration->getMatchingGroups($term); $fromCollector = $this->addressCollector->searchAddress($userId, $term); // Convert collected addresses into same format as CI creates $recipientsFromCollector = array_map(static fn (CollectedAddress $address) => [ 'id' => $address->getId(), 'label' => $address->getDisplayName(), 'email' => $address->getEmail(), 'source' => 'collector', ], $fromCollector); return array_merge($recipientsFromContacts, $recipientsFromCollector, $recipientGroups); } }