Documentation

RoleManager extends StaticFactory

User Extended by Shawn Clake Class RoleManager User Extended is licensed under the MIT license.

Tags
author

Shawn Clake shawn.clake@gmail.com

link
https://github.com/ShawnClake/UserExtended
license

https://github.com/ShawnClake/UserExtended/blob/master/LICENSE MIT

Handles all interactions with roles on a group level (Global level)

Table of Contents

$group  : mixed
The group instance
$roles  : mixed
A list of roles in that group
__callStatic()  : mixed
Main factory function which utilizes PHP's magic method to call a suffixed factory function on the child class.
countRoles()  : mixed
Returns a count of roles in the selected group
createRole()  : Role
Creates a role and returns it after saving
deleteRole()  : mixed
Deletes a role TODO: Reset the role_id in UsersGroups associations back to 0 where this role was used. I believe this has been done now but should be checked before removing this TODO
factory()  : mixed
Helper function which can also be used to simply create an instance of a child class in cases where initialization functions aren't needed.
findRole()  : mixed
Finds and returns a role via RoleCode
fixRoleSort()  : mixed
Fixes the role sort order
getRole()  : bool
Returns a role model by passing a role code in.
getRoles()  : Role
Returns all the roles inside of a group
getSortedGroupRoles()  : array<string|int, mixed>
Gets a list of roles in a group and sorts it by sort_order Useful for promoting, demoting, and getting a sense of hierarchy.
getUnassignedRoles()  : mixed
Returns a list of roles not currently related to a group.
saveRoles()  : mixed
Goes through the roles attached to this instance and runs ->save() on each
setGroup()  : $this
Filling the class with roles for the group code passed to this function
sort()  : $this
Sorts the Collection of Roles by sort_order
sortDown()  : mixed
Moves a role lower down in the heirarchy for that group
sortUp()  : mixed
Moves a role higher up in the heirarchy for that group
updateRole()  : bool|Validator
Updates a role
with()  :
withFactory()  : $this
Fills the class with a group model and role models for the group code passed in.

Properties

$roles

A list of roles in that group

private mixed $roles

Methods

__callStatic()

Main factory function which utilizes PHP's magic method to call a suffixed factory function on the child class.

public static __callStatic( $name,  $arguments) : mixed
Parameters
$name :
$arguments :
Return values
mixed

countRoles()

Returns a count of roles in the selected group

public countRoles() : mixed
Return values
mixed

createRole()

Creates a role and returns it after saving

public static createRole( $name,  $description,  $code, int $groupId) : Role
Parameters
$name :
$description :
$code :
$groupId : int
Return values
Role

deleteRole()

Deletes a role TODO: Reset the role_id in UsersGroups associations back to 0 where this role was used. I believe this has been done now but should be checked before removing this TODO

public static deleteRole( $roleCode) : mixed
Parameters
$roleCode :
Return values
mixed

factory()

Helper function which can also be used to simply create an instance of a child class in cases where initialization functions aren't needed.

public static factory() : mixed

Generally you will want to use the static magic method below.

Return values
mixed

findRole()

Finds and returns a role via RoleCode

public static findRole( $roleCode) : mixed
Parameters
$roleCode :
Return values
mixed

fixRoleSort()

Fixes the role sort order

public fixRoleSort() : mixed
Return values
mixed

getRole()

Returns a role model by passing a role code in.

public getRole( $roleCode) : bool

This will only return a role if the role exists in the group.

Parameters
$roleCode :
Return values
bool

getRoles()

Returns all the roles inside of a group

public getRoles() : Role
Return values
Role

getSortedGroupRoles()

Gets a list of roles in a group and sorts it by sort_order Useful for promoting, demoting, and getting a sense of hierarchy.

public getSortedGroupRoles() : array<string|int, mixed>
Return values
array<string|int, mixed>

getUnassignedRoles()

Returns a list of roles not currently related to a group.

public static getUnassignedRoles() : mixed
Return values
mixed

saveRoles()

Goes through the roles attached to this instance and runs ->save() on each

public saveRoles() : mixed
Return values
mixed

setGroup()

Filling the class with roles for the group code passed to this function

public setGroup( $code) : $this
Parameters
$code :
Return values
$this

sort()

Sorts the Collection of Roles by sort_order

public sort() : $this
Return values
$this

sortDown()

Moves a role lower down in the heirarchy for that group

public sortDown( $roleSortOrder) : mixed
Parameters
$roleSortOrder :
Return values
mixed

sortUp()

Moves a role higher up in the heirarchy for that group

public sortUp( $roleSortOrder) : mixed
Parameters
$roleSortOrder :
Return values
mixed

updateRole()

Updates a role

public static updateRole( $roleCode[, null $sortOrder = null ][, null $name = null ][, null $description = null ][, null $code = null ][, null $groupId = null ][, bool $ignoreChecks = false ]) : bool|Validator
Parameters
$roleCode :
$sortOrder : null = null
$name : null = null
$description : null = null
$code : null = null
$groupId : null = null
$ignoreChecks : bool = false
Return values
bool|Validator

with()

public static with(mixed $groupCode) :

RoleManager

Parameters
$groupCode : mixed
Return values

withFactory()

Fills the class with a group model and role models for the group code passed in.

public withFactory( $groupCode) : $this
Parameters
$groupCode :
Return values
$this

Search results