src/Security/DefaultAdminService.php
protected function findOrCreateAdminGroup()
    {
        // Check pre-existing group
        $adminGroup = Permission::get_groups_by_permission('ADMIN')->first();
        if ($adminGroup) {
            return $adminGroup;
        }

        // Check if default records create the group
        Group::singleton()->requireDefaultRecords();
        $adminGroup = Permission::get_groups_by_permission('ADMIN')->first();
        if ($adminGroup) {
            return $adminGroup;
        }

        // Create new admin group directly
        $adminGroup = Group::create();
        $adminGroup->Code = 'administrators';
        $adminGroup->Title = _t('SilverStripe\\Security\\Group.DefaultGroupTitleAdministrators', 'Administrators');
        $adminGroup->Sort = 0;
        $adminGroup->write();
        Permission::grant($adminGroup->ID, 'ADMIN');
        return $adminGroup;
    }
protected function findOrCreateAdminGroup()
    {
        // Check pre-existing group
        $adminGroup = Permission::get_groups_by_permission('ADMIN')->first();
        if ($adminGroup) {
            return $adminGroup;
        }

        // Check if default records create the group
        Group::singleton()->requireDefaultRecords();
        $adminGroup = Permission::get_groups_by_permission('ADMIN')->first();
        if ($adminGroup) {
            return $adminGroup;
        }

        // Create new admin group directly
        $adminGroup = Group::create();
        $adminGroup->Code = 'administrators';
        $adminGroup->Title = _t('SilverStripe\\Security\\Group.DefaultGroupTitleAdministrators', 'Administrators');
        $adminGroup->Sort = 0;
        $adminGroup->write();
        Permission::grant($adminGroup->ID, 'ADMIN');
        return $adminGroup;
    }
protected function findOrCreateAdminGroup ( ) { // Check pre-existing group $ adminGroup = Permission :: get_groups_by_permission ( 'ADMIN' ) -> first ( ) ; if ( $ adminGroup ) { return $ adminGroup ; } // Check if default records create the group Group :: singleton ( ) -> requireDefaultRecords ( ) ; $ adminGroup = Permission :: get_groups_by_permission ( 'ADMIN' ) -> first ( ) ; if ( $ adminGroup ) { return $ adminGroup ; } // Create new admin group directly $ adminGroup = Group :: create ( ) ; $ adminGroup -> Code = 'administrators' ; $ adminGroup -> Title = _t ( 'SilverStripe\\Security\\Group.DefaultGroupTitleAdministrators' , 'Administrators' ) ; $ adminGroup -> Sort = 0 ; $ adminGroup -> write ( ) ; Permission :: grant ( $ adminGroup -> ID , 'ADMIN' ) ; return $ adminGroup ; }
Ensure a Group exists with admin permission

@return Group
Ensure a Group exists with admin permission