src/Security/Member.php
public function addToGroupByCode($groupcode, $title = "")
    {
        $group = DataObject::get_one(Group::class, array(
            '"Group"."Code"' => $groupcode
        ));

        if ($group) {
            $this->Groups()->add($group);
        } else {
            if (!$title) {
                $title = $groupcode;
            }

            $group = new Group();
            $group->Code = $groupcode;
            $group->Title = $title;
            $group->write();

            $this->Groups()->add($group);
        }
    }
public function addToGroupByCode($groupcode, $title = "")
    {
        $group = DataObject::get_one(Group::class, array(
            '"Group"."Code"' => $groupcode
        ));

        if ($group) {
            $this->Groups()->add($group);
        } else {
            if (!$title) {
                $title = $groupcode;
            }

            $group = new Group();
            $group->Code = $groupcode;
            $group->Title = $title;
            $group->write();

            $this->Groups()->add($group);
        }
    }
public function addToGroupByCode ( $ groupcode , $ title = "" ) { $ group = DataObject :: get_one ( Group :: class , array ( '"Group"."Code"' => $ groupcode ) ) ; if ( $ group ) { $ this -> Groups ( ) -> add ( $ group ) ; } else { if ( ! $ title ) { $ title = $ groupcode ; } $ group = new Group ( ) ; $ group -> Code = $ groupcode ; $ group -> Title = $ title ; $ group -> write ( ) ; $ this -> Groups ( ) -> add ( $ group ) ; } }
Adds the member to a group. This will create the group if the given
group code does not return a valid group object.

@param string $groupcode
@param string $title Title of the group
Adds the member to a group . This will create the group if the given group code does not return a valid group object .