FOS\UserBundle\Model\GroupManagerInterface::findGroups PHP Method

findGroups() public method

Returns a collection with all user instances
public findGroups ( ) : Traversable
return Traversable
    function findGroups();

Usage Example

 public function setUpGroupNamespaces()
 {
     global $wgExtraNamespaces, $wgNamespacePermissionLockdown, $wgNonincludableNamespaces;
     if (!$wgNamespacePermissionLockdown || !$wgNonincludableNamespaces) {
         throw new \Exception('To use the Group Namespace Feature you need to install Lockdown (https://www.mediawiki.org/wiki/Extension:Lockdown)');
     }
     $nsCount = 200;
     $groups = $this->groupmanager->findGroups();
     foreach ($groups as $group) {
         $nsName = 'NS_SF_GROUP_' . $group->getId();
         $nsNameTalk = $nsName . '_TALK';
         define($nsName, $nsCount++);
         define($nsNameTalk, $nsCount++);
         $groupName = $group->getName();
         $groupName = strtolower($groupName);
         $groupName = str_replace(array(' ', ',', '.', '-'), '_', $groupName);
         $groupName = ucfirst($groupName);
         # add new namespaces
         $wgExtraNamespaces[constant($nsName)] = $groupName;
         $wgExtraNamespaces[constant($nsNameTalk)] = $groupName . '_talk';
         #restrict "read" permission to logged in users
         $wgNamespacePermissionLockdown[constant($nsName)]['read'] = array(self::getGroupAlias($group));
         $wgNamespacePermissionLockdown[constant($nsNameTalk)]['read'] = array(self::getGroupAlias($group));
         #prevent inclusion of pages from that namespace
         $wgNonincludableNamespaces[] = constant($nsName);
         $wgNonincludableNamespaces[] = constant($nsNameTalk);
     }
 }