Transform an array of group id to ArrayCollection of groups

@param array $groups

@return ArrayCollection
557617
public function reverseTransform($groups)
    {
        $value = new ArrayCollection();
        if (is_array($groups) && array_key_exists('groups_collection', $groups)) {
            $groups = $groups['groups_collection'];
            foreach ($groups as $groupId => $group) {
                if (array_key_exists('group', $group) && $group['group']) {
                    $group = $this->groupRepository->find($groupId);
                    if (null !== $group && in_array($group->getSite()->getId(), $this->availableSiteIds)) {
                        $value->add($group);
                    }
                }
            }
        }

        return $value;
    }
1033450
public function transform($groupCollection, array $params = array())
    {
        $nbrGroupsUsers = array_key_exists('nbrGroupsUsers', $params) ? $params['nbrGroupsUsers'] : array();
        $facade = $this->newFacade();

        foreach ($groupCollection as $group) {
            $facade->addGroup($this->getContext()->transform('group', $group, array('nbrGroupsUsers' => $nbrGroupsUsers)));
        }

        return $facade;
    }
801810
public function setGroups(array $groups)
    {
        $this->groups = [];

        foreach ($groups as $groupIdent => $group) {
            $this->addGroup($groupIdent, $group);
        }

        uasort($this->groups, [ $this, 'sortGroupsByPriority' ]);

        // Remove items that are not active.
        $this->groups = array_filter($this->groups, function($item) {
            return ($item->active());
        });

        return $this;
    }
102572
public static function fromCollection($collection) {
		if (!(is_array($collection) || $collection instanceof Iterator)) {
			throw new InvalidArgumentException('$collection is neither an array nor an iterator');
		}

		return self::toCollection($collection);
	}
814315
public function setGroups(array $groups)
    {
        $this->groups = [];

        foreach ($groups as $groupIdent => $group) {
            $this->addGroup($groupIdent, $group);
        }

        return $this;
    }
1138226
public static function wrapMany(array $keys)
    {
        foreach ($keys as &$key) {
            $key = self::wrap($key);
        }

        return $keys;
    }
1349661
protected function groupsConditionalLogic(array $groups = null)
    {
        if (!$groups) {
            $groups = iterator_to_array($this->groups());
        }

        $conditions = [];

        foreach ($groups as $group) {
            if ($group instanceof FormInterface) {
                $groupGroups = iterator_to_array($group->groups());
                if (!empty($groupGroups)) {
                    $conditions = array_merge(
                        $conditions,
                        $this->groupsConditionalLogic($groupGroups)
                    );
                }
            }

            if ($group instanceof FormGroupInterface && $group->conditionalLogic()) {
                $conditions = array_merge($conditions, $group->conditionalLogic());
            }
        }

        return $conditions;
    }
381203
public function zip($keys) : Collection
    {
        if (!is_array($keys)) {
            $keys = iterator_to_array($keys);
        }
        return new static(array_combine($keys, $this->toArray()));
    }
1294168
public function setCollectors(array $collectors)
    {
        $this->collectors = array();

        // add new collectors in way that ensures that
        // keys are collector names and are not added twice
        foreach ($collectors as $c)
        {
            $this->addCollector($c);
        }

        return $this;
    }
1241054
public function groupBy(...$groups)
    {
        foreach ($groups as $group) {
            $this->groups = array_merge(
                (array) $this->groups,
                array_wrap($group)
            );
        }

        return $this;
    }
44112
public function merge($collections = [])
    {
        $collections = func_get_args();

        array_unshift($collections, $this);
        foreach ($collections as &$collection) {
            $collection = (array) $collection;
        }
        unset($collection);

        $merged = call_user_func_array('array_merge', $collections);

        $collections = clone $this;
        $collections->exchangeArray($merged);

        return $collections;
    }
454778
public function addUserGroups(UserGroup ...$groups)
    {
        foreach ($groups as $group) {
            $this->getUserGroups()->add($group);
        }

        return $this;
    }
73727
public function mget(array $keys)
	{
		$items = array();

		foreach ($keys as $key) {
		    $items[$key] = $this->get($key);
		}
		
		return $items;
	}
733448
private function getObjectStateGroupsIds(array $groups): array
    {
        $groupsIds = array_column($groups, 'id');

        return array_combine($groupsIds, array_fill_keys($groupsIds, false));
    }
1252232
public function reverseTransform($array)
    {
        $ret = new ArrayCollection();

        foreach ($array as $el) {
            $ret->add(
                $this->em
                    ->getRepository($this->class)
                    ->find($el)
            );
        }
        return $ret;
    }
49781
public function toArray(array $keys = [])
    {
        $data = parent::toArray($keys);

        if (in_array('url', $keys) || empty($keys)) {
            $data['url'] = $this->getUrl();
        }

        if (in_array('is_selected', $keys) || empty($keys)) {
            $data['is_selected'] = (bool) $this->getIsSelected();
        }

        return $data;
    }
1042477
public function all(array $collections = [], $groupByCollection = false)
    {
        if (count($collections) === 0) {
            if ($groupByCollection === false) {
                return $this->items;
            }

            return $this->itemCollections;
        }

        $result = [];

        foreach ($collections as $collection) {
            if (isset($this->itemCollections[$collection]) === false) {
                continue;
            }

            if ($groupByCollection === false) {
                $result = array_merge($result, $this->itemCollections[$collection]);

                continue;
            }

            $result[$collection] = $this->itemCollections[$collection];
        }

        return $result;
    }