Organization
extends AuthenticationEntity
in package
Uses
Permission, RetrievalTrait, HandleTrait
Table of Contents
- $dbExpression : array<string|int, mixed>
- $dbPermissionsObjectColumn : string
- $dbPermissionsTable : string
- $dbTable : string
- __construct() : mixed
- add() : Organization
- all() : array<string|int, static>
- Get a list of all active objects of the calling class (user, role, session, organization, API key)
- buildPermissionVariants() : array<string|int, string>
- Build permission variants for a given permission name
- byAccessToAll() : array<string|int, mixed>
- byAccessToAnyOf() : array<string|int, mixed>
- byGroup() : array<string|int, mixed>
- byId() : static|null
- Get an object (user, role, session, organization or API key) by its id
- byIdentifier() : object|null
- Get a permission object (user or role) by one of its identifiers
- byIdentifiers() : array<string|int, object>
- Get a list of permission objects (user or role) by one of their identifiers
- byIds() : array<string|int, static>
- Get a list of objects (user, role, session, organization or API key) by their ids Unknown or inactive ids are skipped, and calling it without ids throws a database exception
- byName() : array<string|int, Organization>
- Get all active organizations matching the given name.
- byRole() : array<string|int, mixed>
- byUser() : Organization|null
- Get the organization a given user belongs to.
- byUuid() : object|null
- Get a permission object (user or role) by its uuid
- byUuids() : array<string|int, object>
- Get a list of permission objects (user or role) by their uuids
- getGroup() : Group|null
- getGroups() : array<string|int, mixed>
- getPermissions() : array<string|int, mixed>
- getRoles() : array<string|int, mixed>
- getUsers() : array<string|int, mixed>
- groupsAdd() : void
- groupsRemove() : void
- hasAccessAll() : bool
- Check if the permission object (user or role) has all of the given permissions, wildcards count ("*.*" or "edit.*" cover "edit.article") and a user's permissions include those inherited from its roles
- hasAccessAnyOf() : bool
- Check if the permission object (user or role) has one of the permissions, wildcards included ("*.*" or "edit.*" cover "edit.article"); a user's role-inherited permissions count too
- hasMember() : bool
- loadObject() : mixed
- maxCapacity() : int|null
- name() : string
- permissionsAdd() : void
- Add permissions to an permission object (user or role)
- permissionsRemove() : void
- Remove permissions from the permission object (user or role)
- refresh() : void
- Refresh the current permission object (user, role, session, organization or API key) by clearing all its fields and setting them new
- refreshGroup() : void
- refreshPermissions() : void
- refreshUsers() : void
- remove() : void
- rolesAdd() : void
- rolesRemove() : void
- updateMaxCapacity() : void
- updateName() : void
Properties
$dbExpression
public
static array<string|int, mixed>
$dbExpression
= []
$dbPermissionsObjectColumn
public
static string
$dbPermissionsObjectColumn
= "organization"
$dbPermissionsTable
public
static string
$dbPermissionsTable
= "z_organization_permission"
$dbTable
public
static string
$dbTable
= "z_organization"
Methods
__construct()
public
__construct(array<string|int, mixed> $data) : mixed
Parameters
- $data : array<string|int, mixed>
Return values
mixed —add()
public
static add(string|null $name[, bool $createGroup = false ][, string|null $groupName = null ][, int|null $maxCapacity = null ]) : Organization
Parameters
- $name : string|null
- $createGroup : bool = false
- $groupName : string|null = null
- $maxCapacity : int|null = null
Return values
Organization —all()
Get a list of all active objects of the calling class (user, role, session, organization, API key)
public
static all() : array<string|int, static>
Return values
array<string|int, static> —The list of active objects
buildPermissionVariants()
Build permission variants for a given permission name
public
static buildPermissionVariants(string $permissionName) : array<string|int, string>
e.g. "edit.article" => [".", "edit.", "edit.article.", "edit.article"]
Parameters
- $permissionName : string
-
The permission name to build variants for
Return values
array<string|int, string> —An array of permission variants
byAccessToAll()
public
static byAccessToAll(string ...$permissionNames) : array<string|int, mixed>
Parameters
- $permissionNames : string
Return values
array<string|int, mixed> —byAccessToAnyOf()
public
static byAccessToAnyOf(string ...$permissionNames) : array<string|int, mixed>
Parameters
- $permissionNames : string
Return values
array<string|int, mixed> —byGroup()
public
static byGroup(Group $group) : array<string|int, mixed>
Parameters
- $group : Group
Return values
array<string|int, mixed> —byId()
Get an object (user, role, session, organization or API key) by its id
public
static byId(int|string $id) : static|null
Parameters
- $id : int|string
-
the id of the object
Return values
static|null —the object if found, null if the id is unknown or inactive
byIdentifier()
Get a permission object (user or role) by one of its identifiers
public
static byIdentifier(string $column, int|string $identifier) : object|null
Parameters
- $column : string
-
The identifying column, e.g. "id" or "uuid"
- $identifier : int|string
-
The value of the identifying column
Return values
object|null —the permission object if found, null otherwise
byIdentifiers()
Get a list of permission objects (user or role) by one of their identifiers
public
static byIdentifiers(string $column, array<string|int, int>|array<string|int, string> $identifiers) : array<string|int, object>
Parameters
- $column : string
-
The identifying column, e.g. "id" or "uuid"
- $identifiers : array<string|int, int>|array<string|int, string>
-
The values of the identifying column
Return values
array<string|int, object> —The list of permission objects
byIds()
Get a list of objects (user, role, session, organization or API key) by their ids Unknown or inactive ids are skipped, and calling it without ids throws a database exception
public
static byIds(int ...$ids) : array<string|int, static>
Parameters
- $ids : int
-
The ids of the objects to retrieve
Return values
array<string|int, static> —the objects that were found
byName()
Get all active organizations matching the given name.
public
static byName(string $name) : array<string|int, Organization>
Organization names are not unique, so this returns an array - possibly empty, possibly containing multiple organizations sharing the same name.
Parameters
- $name : string
-
The name to match exactly
Return values
array<string|int, Organization> —All active organizations with the given name
byRole()
public
static byRole(Role $role) : array<string|int, mixed>
Parameters
- $role : Role
Return values
array<string|int, mixed> —byUser()
Get the organization a given user belongs to.
public
static byUser(User $user) : Organization|null
Convenience pass-through to User::organization() so callers can use the
symmetric Organization::byUser($user) style alongside other by* retrievers.
Parameters
- $user : User
-
The user to look up
Return values
Organization|null —The organization or null if the user has none
byUuid()
Get a permission object (user or role) by its uuid
public
static byUuid(string $uuid) : object|null
Parameters
- $uuid : string
-
the uuid of the object
Return values
object|null —the permission object if found, null otherwise
byUuids()
Get a list of permission objects (user or role) by their uuids
public
static byUuids(string ...$uuids) : array<string|int, object>
Parameters
- $uuids : string
-
The uuids of the objects to retrieve
Return values
array<string|int, object> —The list of permission objects
getGroup()
public
getGroup() : Group|null
Return values
Group|null —getGroups()
public
getGroups() : array<string|int, mixed>
Return values
array<string|int, mixed> —getPermissions()
public
getPermissions() : array<string|int, mixed>
Return values
array<string|int, mixed> —getRoles()
public
getRoles() : array<string|int, mixed>
Return values
array<string|int, mixed> —getUsers()
public
getUsers() : array<string|int, mixed>
Return values
array<string|int, mixed> —groupsAdd()
public
groupsAdd(Group ...$groups) : void
Parameters
- $groups : Group
Return values
void —groupsRemove()
public
groupsRemove(Group ...$groups) : void
Parameters
- $groups : Group
Return values
void —hasAccessAll()
Check if the permission object (user or role) has all of the given permissions, wildcards count ("*.*" or "edit.*" cover "edit.article") and a user's permissions include those inherited from its roles
public
hasAccessAll(array<string|int, string> ...$permissionNames) : bool
Parameters
- $permissionNames : array<string|int, string>
-
The names of the permissions to check
Return values
bool —True if the object has all of the permissions, false otherwise
hasAccessAnyOf()
Check if the permission object (user or role) has one of the permissions, wildcards included ("*.*" or "edit.*" cover "edit.article"); a user's role-inherited permissions count too
public
hasAccessAnyOf(array<string|int, string> ...$permissionNames) : bool
Parameters
- $permissionNames : array<string|int, string>
-
The names of the permissions to check
Return values
bool —True if the object has at least one of the permissions, false otherwise
hasMember()
public
hasMember(User $user) : bool
Parameters
- $user : User
Return values
bool —loadObject()
public
loadObject(array<string|int, mixed> $data) : mixed
Parameters
- $data : array<string|int, mixed>
Return values
mixed —maxCapacity()
public
maxCapacity() : int|null
Return values
int|null —name()
public
name() : string
Return values
string —permissionsAdd()
Add permissions to an permission object (user or role)
public
permissionsAdd(array<string|int, string> ...$permissionNames) : void
Parameters
- $permissionNames : array<string|int, string>
-
The names of the permissions to add
Return values
void —permissionsRemove()
Remove permissions from the permission object (user or role)
public
permissionsRemove(array<string|int, string> ...$permissionNames) : void
Parameters
- $permissionNames : array<string|int, string>
-
The names of the permissions to remove
Return values
void —refresh()
Refresh the current permission object (user, role, session, organization or API key) by clearing all its fields and setting them new
public
refresh() : void
Tags
Return values
void —refreshGroup()
public
refreshGroup() : void
Return values
void —refreshPermissions()
public
refreshPermissions() : void
Return values
void —refreshUsers()
public
refreshUsers() : void
Return values
void —remove()
public
remove() : void
Return values
void —rolesAdd()
public
rolesAdd(Role ...$roles) : void
Parameters
- $roles : Role
Return values
void —rolesRemove()
public
rolesRemove(Role ...$roles) : void
Parameters
- $roles : Role
Return values
void —updateMaxCapacity()
public
updateMaxCapacity(int|null $maxCapacity) : void
Parameters
- $maxCapacity : int|null
Return values
void —updateName()
public
updateName(string $name) : void
Parameters
- $name : string