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;
    }
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;
    }
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 ; }
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.

@param \AppserverIo\Lang\String                     $name       The name of the group to create
@param \AppserverIo\Collections\CollectionInterface $principals The list of principals

@return \AppserverIo\Psr\Security\Acl\GroupInterface A named group from the principals set
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 .