(using Symfony 3.4)
I am trying to create an array collection by merging (getting only the objects) multiple collections. Sounds weird, let me explain.
I take all the users from the db and for each one I want to add in a single array collection all his/her licenses. My code:
$users = $this->userRepository->findAllUsers($params);
$users->forAll(function (User $user) use (&$array) {
$array = array_merge($array, $user->getLicenses());
});
$a = new ArrayCollection($array);
How should I resolve this?