Imbo\Auth\AccessControl\Adapter\Mongo::getGroups PHP Method

getGroups() public method

public getGroups ( Imbo\Auth\AccessControl\GroupQuery $query = null, Groups $model )
$query Imbo\Auth\AccessControl\GroupQuery
$model Imbo\Model\Groups
    public function getGroups(GroupQuery $query = null, GroupsModel $model)
    {
        if ($query === null) {
            $query = new GroupQuery();
        }
        $cursor = $this->getGroupsCollection()->find([], ['skip' => ($query->page() - 1) * $query->limit(), 'limit' => $query->limit()]);
        $groups = [];
        foreach ($cursor as $group) {
            $groups[$group['name']] = $group['resources']->getArrayCopy();
        }
        // Cache the retrieved groups
        $this->groups = array_merge($this->groups, $groups);
        // Update model with total hits
        $model->setHits($this->getGroupsCollection()->count());
        return $groups;
    }