Skip to content

Instantly share code, notes, and snippets.

@woprrr
Created March 8, 2019 13:56
Show Gist options
  • Save woprrr/5140615371b86560e87064e37578de49 to your computer and use it in GitHub Desktop.
Save woprrr/5140615371b86560e87064e37578de49 to your computer and use it in GitHub Desktop.
/**
* Populate organisation with given already existing user list.
*
* @param array $userList
*
* @return \Doctrine\Common\Collections\ArrayCollection
*/
private function populateUsers(array $userList): ArrayCollection
{
$collection = new ArrayCollection();
foreach ($userList as $userId) {
if ($collection->contains($userId)) {
continue;
}
$user = $this->userRepository->find($userId);
if ($user) {
$collection[] = $user;
}
}
return $collection;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment