private function createRole($rolename, $machine_name)
    {
        $role = Role::create(
            [
                'id' => $machine_name,
                'label' => $rolename,
                'originalId' => $machine_name
            ]
        );

        $result = [];

        try {
            $role->save();

            $result['success'][] = [
                'role-id' => $role->id(),
                'role-name' => $role->get('label')
            ];
        } catch (\Exception $e) {
            $result['error'] = [
                'vid' => $role->id(),
                'name' => $role->get('label'),
                'error' => 'Error: ' . get_class($e) . ', code: ' . $e->getCode() . ', message: ' . $e->getMessage()
            ];
        }

        return $result;
    }
private function createRole($rolename, $machine_name)
    {
        $role = Role::create(
            [
                'id' => $machine_name,
                'label' => $rolename,
                'originalId' => $machine_name
            ]
        );

        $result = [];

        try {
            $role->save();

            $result['success'][] = [
                'role-id' => $role->id(),
                'role-name' => $role->get('label')
            ];
        } catch (\Exception $e) {
            $result['error'] = [
                'vid' => $role->id(),
                'name' => $role->get('label'),
                'error' => 'Error: ' . get_class($e) . ', code: ' . $e->getCode() . ', message: ' . $e->getMessage()
            ];
        }

        return $result;
    }
private function createRole ( $ rolename , $ machine_name ) { $ role = Role :: create ( [ 'id' => $ machine_name , 'label' => $ rolename , 'originalId' => $ machine_name ] ) ; $ result = [ ] ; try { $ role -> save ( ) ; $ result [ 'success' ] [ ] = [ 'role-id' => $ role -> id ( ) , 'role-name' => $ role -> get ( 'label' ) ] ; } catch ( \ Exception $ e ) { $ result [ 'error' ] = [ 'vid' => $ role -> id ( ) , 'name' => $ role -> get ( 'label' ) , 'error' => 'Error: ' . get_class ( $ e ) . ', code: ' . $ e -> getCode ( ) . ', message: ' . $ e -> getMessage ( ) ] ; } return $ result ; }
Create and returns an array of new role

@param $rolename
@param $machine_name

@return $array
Create and returns an array of new role