Get a user group (create it if it does not exist).

@param string $name the group name
@param string|Group|null $parent the parent group

@return \Group
190051
protected function getGroup($name, $parent = null)
    {
        $name = trim($name, '/');
        if ($parent === null || $parent === false || $parent === '') {
            $parent = null;
            $path = '/' . $name;
        } else {
            if (!$parent instanceof Group) {
                $parent = $this->getGroup($parent);
            }
            $path = '/' . $parent->getGroupName() . '/' . $name;
        }
        $result = \Group::getByPath($path);
        if (!$result) {
            $result = \Group::add($name, '', $parent, $this->getPackage());
            if (!$result) {
                if ($parent) {
                    throw new UserMessageException(t("Failed to create a user group with name '%1\$s' as a child of '%2\$s'", $name, $parent->getGroupName()));
                } else {
                    throw new UserMessageException(t("Failed to create a user group with name '%s'", $name));
                }
            }
        }

        return $result;
    }
109174
public function callGroup($name, $parameters = array())
    {
        if (!$this->hasGroup($name)) {
            return;
        }

        $result = '';

        foreach ($this->groups[$name] as $key => $widget) {
            $result .= $this->get($widget, array_get($parameters, $key, array()));
        }

        return $result;
    }
1117901
protected function getUserGroup($groupName)
    {
        $groupName = "admin:$groupName";

        $group = $this->userGroupFactory->getGroup($groupName);
        if (!$group) {
            $this->userGroupFactory->create($groupName);
            $group = $this->userGroupFactory->getGroup($groupName);
        }

        return $group;
    }
1010920
public function get($name, $parameters = null)
    {
        $instance = parent::get($name, $parameters);

        if (is_object($instance) && $instance instanceof EventsAwareInterface) {
            if (!$instance->getEventsManager() && ($eventsManager = $this->getEventsManager())) {
                $instance->setEventsManager($eventsManager);
            }
        }

        return $instance;
    }
1007032
public function assertUserWithNameDoesntExistInGroup( $username, $parentGroup )
    {
        Assertion::assertFalse(
            $this->getUserManager()->checkUserExistenceByUsername( $username, $parentGroup ),
            "User with name '$username' was found in parent group '$parentGroup'."
        );
    }
895213
public function findByName($name)
	{
		$model = $this->createModel();

		if ( ! $group = $model->newQuery()->where('name', '=', $name)->first())
		{
			throw new GroupNotFoundException("A group could not be found with the name [$name].");
		}

		return $group;
	}
325665
public function addGroup($parent, $child)
    {
        // Find the parent group's dn
        $parentDn = $this->dn($parent);

        $childDn = $this->dn($child);

        if ($parentDn && $childDn) {
            $add['member'] = $childDn;

            // Add the child to the parent group and return the result
            return $this->connection->modAdd($parentDn, $add);
        }

        return false;
    }
242459
public function getGroupForName($name)
    {
        if (!$this->accessControlManager->hasAccessEntityForName(self::ACCESS_ENTITY_TYPE, $name)) {
            return false;
        }
        
        // Get the access entity
        $accessEntity = $this->accessControlManager->getAccessEntityForName(self::ACCESS_ENTITY_TYPE, $name);

        if ($accessEntity === false) {
            return false;
        }
        
        return $accessEntity;
    }
32484
public function getParentBlock($name)
    {
        if ($this->tpl->parent == null) {
            return null;
        }
        $block = $this->getBlockCache($name);
        if ($block != null) {
            return $block;
        }
        $pcomplie = $this->tpl->parent->getCompiler();
        $temp = $pcomplie->getVarTemp();
        $pcomplie->setVarTemp($this->getVarTemp());
        $block = $pcomplie->compileBlock($name);
        $pcomplie->setVarTemp($temp);
        $this->addBlockCache($name, $block);
        return $block;
    }
666865
public function getAggregation($name)
    {
        $aggregations = parent::getAggregations();
        if (!array_key_exists($name, $aggregations)) {
            return null;
        }

        return new AggregationValue($aggregations[$name]);
    }
45075
protected function findConstraintGroup($name) {
        foreach ($this->getConstraintGroups() as $group) {
            if ($group->getName() === $name) {
                return $group;
            }
        }

        return null;
    }
1167477
public function getClient($group, $name)
    {
        return isset($this[$group][$name]) ? $this[$group][$name] : null;
    }
836187
function user_ingroup($username,$group,$recursive=NULL){
        if ($username==NULL){ return (false); }
        if ($group==NULL){ return (false); }
        if (!$this->_bind){ return (false); }
        if ($recursive==NULL){ $recursive=$this->_recursive_groups; } //use the default option if they haven't set it
        
        //get a list of the groups
        $groups=$this->user_groups($username,array($this->_group_attribute),$recursive);
        
        //return true if the specified group is in the group list
        if (in_array($group,$groups)){ return (true); }

        return (false);
    }
769617
public function getGroupIdByName($name)
    {
        if (!isset($this->groups)) {
            $this->resetCraftSitesServiceGroupsCache();

            $this->groups = [];
            foreach (Craft::$app->sites->getAllGroups() as $group) {
                $this->groups[$group->name] = $group->id;
            }
        }
        if (!array_key_exists($name, $this->groups)) {
            $group = new SiteGroup(['name' => $name]);
            if (Craft::$app->sites->saveGroup($group)) {
                $this->groups[$name] = $group->id;
            } else {
                Schematic::importError($group, $name);

                return null;
            }
        }

        return $this->groups[$name];
    }
651173
public function getDisplayGroup($name)
    {
        if ($group = parent::getDisplayGroup($name)) {
            return $group;
        } else {
            $subforms = $this->getSubForms();
            foreach($subforms as $subform) {
                if ($group = $subform->getDisplayGroup($name)) {
                    return $group;
                }
            }
            return;
        }
    }
601813
public function groupsAction($name)
    {
        $server = $this->ldap->get($name);
        $user = isset($server['user']) ? $server['user'] : null;
        $password = isset($server['password']) ? $server['password'] : null;

        if ($this->ldap->connect($server, $user, $password)) {
            $classes = $this->ldap->getClasses($server);
            $groups = $this->ldap->getGroups($server);
            $this->ldap->close();

            return [
                'server' => $server,
                'groups' => $groups,
                'groupsJSON' => json_encode($groups),
                'classes' => $classes,
            ];
        }

        return ['error' => true];
    }
261211
public function getGroupByName($name)
    {
        if (!array_key_exists($name, $this->groups)) {
            throw new \InvalidArgumentException(sprintf('Can\'t find "%s" group.', $name));
        }

        return $this->groups[$name];
    }