AppserverIo\Appserver\ServletEngine\Security\Auth\Spi\AbstractLoginModule::createGroup PHP Метод

createGroup() защищенный Метод

Find or create a Group with the given name. Subclasses should use this method to locate the 'Roles' group or create additional types of groups.
protected createGroup ( string $name, AppserverIo\Collections\CollectionInterface $principals ) : AppserverIo\Psr\Security\Acl\GroupInterface
$name string The name of the group to create
$principals AppserverIo\Collections\CollectionInterface The list of principals
Результат AppserverIo\Psr\Security\Acl\GroupInterface A named group from the principals set
    protected function createGroup(string $name, CollectionInterface $principals)
    {
        // initialize the group
        /** \AppserverIo\Psr\Security\Acl\GroupInterface $roles */
        $roles = null;
        // iterate over the passed principals
        foreach ($principals as $principal) {
            // query whether we found a group or not, proceed if not
            if ($principal instanceof GroupInterface == false) {
                continue;
            }
            // the principal is a group
            $grp = $principal;
            // if the group already exists, stop searching
            if ($grp->getName()->equals($name)) {
                $roles = $grp;
                break;
            }
        }
        // if we did not find a group create one
        if ($roles == null) {
            $roles = new SimpleGroup($name);
            $principals->add($roles);
        }
        // return the group
        return $roles;
    }