class GroupService (View source)

Service for managing user groups

Handles group CRUD operations, visibility filtering, and validation

Methods

__construct(UserGroupRepositoryInterface $groupRepository)

No description

array
listGroups(int $userId, bool $isAdmin)

List groups with visibility filtering

UserGroup|null
getGroupById(int $groupId, int $userId, bool $isAdmin)

Get a group by ID with visibility check

bool
canUserViewGroup(int $groupId, int $userId)

Check if a user can view a group

createGroup(string $name, int $permTemplId, string|null $description = null, int|null $createdBy = null)

Create a new group

updateGroup(int $groupId, string|null $name = null, string|null $description = null, int|null $permTemplId = null)

Update an existing group

bool
deleteGroup(int $groupId)

Delete a group

array
getGroupDetails(int $groupId)

Get group details including member and zone counts

bool
isGroupNameAvailable(string $name, int|null $excludeGroupId = null)

Check if a group name is available

Details

__construct(UserGroupRepositoryInterface $groupRepository)

No description

Parameters

UserGroupRepositoryInterface $groupRepository

array listGroups(int $userId, bool $isAdmin)

List groups with visibility filtering

Parameters

int $userId

Current user ID

bool $isAdmin

Whether the user is an admin (überuser)

Return Value

array

UserGroup|null getGroupById(int $groupId, int $userId, bool $isAdmin)

Get a group by ID with visibility check

Parameters

int $groupId

Group ID

int $userId

Current user ID

bool $isAdmin

Whether the user is an admin

Return Value

UserGroup|null

Exceptions

InvalidArgumentException

bool canUserViewGroup(int $groupId, int $userId)

Check if a user can view a group

Parameters

int $groupId

Group ID

int $userId

User ID

Return Value

bool

UserGroup createGroup(string $name, int $permTemplId, string|null $description = null, int|null $createdBy = null)

Create a new group

Parameters

string $name

Group name (must be unique)

int $permTemplId

Permission template ID

string|null $description

Optional description

int|null $createdBy

User ID who created the group

Return Value

UserGroup

Exceptions

InvalidArgumentException

UserGroup updateGroup(int $groupId, string|null $name = null, string|null $description = null, int|null $permTemplId = null)

Update an existing group

Parameters

int $groupId

Group ID

string|null $name

New name (if provided)

string|null $description

New description (if provided)

int|null $permTemplId

New permission template ID (if provided)

Return Value

UserGroup

Exceptions

InvalidArgumentException

bool deleteGroup(int $groupId)

Delete a group

Cascade deletes will remove all memberships and zone associations

Parameters

int $groupId

Group ID

Return Value

bool

Exceptions

InvalidArgumentException

array getGroupDetails(int $groupId)

Get group details including member and zone counts

Parameters

int $groupId

Group ID

Return Value

array

Exceptions

InvalidArgumentException

bool isGroupNameAvailable(string $name, int|null $excludeGroupId = null)

Check if a group name is available

Parameters

string $name

Group name to check

int|null $excludeGroupId

Group ID to exclude from check (for updates)

Return Value

bool