RoleController extends SimpleController
Controller class for role-related requests, including listing roles, CRUD for roles, etc.
Basic controller class, that imports the entire DI container for easy access to services. Your controller classes may extend this controller class.
Tags
Table of Contents
$ci | ContainerInterface | |
---|---|---|
create() | Processes the request to create a new role. | mixed |
delete() | Processes the request to delete an existing role. | mixed |
getInfo() | Returns info for a single role, along with associated permissions. | mixed |
getList() | Returns a list of Roles. | mixed |
getModalConfirmDelete() | Display deletion confirmation modal. | mixed |
getModalCreate() | Renders the modal form for creating a new role. | mixed |
getModalEdit() | Renders the modal form for editing an existing role. | mixed |
getModalEditPermissions() | Renders the modal form for editing a role's permissions. | mixed |
getPermissions() | Returns a list of Permissions for a specified Role. | mixed |
getUsers() | Returns users associated with a single role. | mixed |
pageInfo() | Renders a page displaying a role's information, in read-only mode. | mixed |
pageList() | Renders the role listing page. | mixed |
updateInfo() | Processes the request to update an existing role's details. | mixed |
updateField() | Processes the request to update a specific field for an existing role, including permissions. | mixed |
getRoleFromParams() | Get role instance from params. | Role |
__construct() | Constructor. | mixed |
Properties
$ci
protected
ContainerInterface
$ci
Methods
create()
Processes the request to create a new role.
public
create(
$request :
ServerRequestInterface
, $response :
ResponseInterface
, $args :
array
)
: mixed
Processes the request from the role creation form, checking that:
- The role name and slug are not already in use;
- The user has permission to create a new role;
- The submitted data is valid. This route requires authentication (and should generally be limited to admins or the root user).
Request type: POST
Parameters
- $request : ServerRequestInterface
- $response : ResponseInterface
- $args : array
Tags
Return values
mixeddelete()
Processes the request to delete an existing role.
public
delete(
$request :
ServerRequestInterface
, $response :
ResponseInterface
, $args :
array
)
: mixed
Deletes the specified role. Before doing so, checks that:
- The user has permission to delete this role;
- The role is not a default for new users;
- The role does not have any associated users;
- The submitted data is valid. This route requires authentication (and should generally be limited to admins or the root user).
Request type: DELETE
Parameters
- $request : ServerRequestInterface
- $response : ResponseInterface
- $args : array
Tags
Return values
mixedgetInfo()
Returns info for a single role, along with associated permissions.
public
getInfo(
$request :
ServerRequestInterface
, $response :
ResponseInterface
, $args :
array
)
: mixed
This page requires authentication.
Request type: GET
Parameters
- $request : ServerRequestInterface
- $response : ResponseInterface
- $args : array
Tags
Return values
mixedgetList()
Returns a list of Roles.
public
getList(
$request :
ServerRequestInterface
, $response :
ResponseInterface
, $args :
array
)
: mixed
Generates a list of roles, optionally paginated, sorted and/or filtered. This page requires authentication.
Request type: GET
Parameters
- $request : ServerRequestInterface
- $response : ResponseInterface
- $args : array
Tags
Return values
mixedgetModalConfirmDelete()
Display deletion confirmation modal.
public
getModalConfirmDelete(
$request :
ServerRequestInterface
, $response :
ResponseInterface
, $args :
array
)
: mixed
Parameters
- $request : ServerRequestInterface
- $response : ResponseInterface
- $args : array
Tags
Return values
mixedgetModalCreate()
Renders the modal form for creating a new role.
public
getModalCreate(
$request :
ServerRequestInterface
, $response :
ResponseInterface
, $args :
array
)
: mixed
This does NOT render a complete page. Instead, it renders the HTML for the modal, which can be embedded in other pages. This page requires authentication.
Request type: GET
Parameters
- $request : ServerRequestInterface
- $response : ResponseInterface
- $args : array
Tags
Return values
mixedgetModalEdit()
Renders the modal form for editing an existing role.
public
getModalEdit(
$request :
ServerRequestInterface
, $response :
ResponseInterface
, $args :
array
)
: mixed
This does NOT render a complete page. Instead, it renders the HTML for the modal, which can be embedded in other pages. This page requires authentication.
Request type: GET
Parameters
- $request : ServerRequestInterface
- $response : ResponseInterface
- $args : array
Tags
Return values
mixedgetModalEditPermissions()
Renders the modal form for editing a role's permissions.
public
getModalEditPermissions(
$request :
ServerRequestInterface
, $response :
ResponseInterface
, $args :
array
)
: mixed
This does NOT render a complete page. Instead, it renders the HTML for the form, which can be embedded in other pages. This page requires authentication.
Request type: GET
Parameters
- $request : ServerRequestInterface
- $response : ResponseInterface
- $args : array
Tags
Return values
mixedgetPermissions()
Returns a list of Permissions for a specified Role.
public
getPermissions(
$request :
ServerRequestInterface
, $response :
ResponseInterface
, $args :
array
)
: mixed
Generates a list of permissions, optionally paginated, sorted and/or filtered. This page requires authentication.
Request type: GET
Parameters
- $request : ServerRequestInterface
- $response : ResponseInterface
- $args : array
Tags
Return values
mixedgetUsers()
Returns users associated with a single role.
public
getUsers(
$request :
ServerRequestInterface
, $response :
ResponseInterface
, $args :
array
)
: mixed
This page requires authentication.
Request type: GET
Parameters
- $request : ServerRequestInterface
- $response : ResponseInterface
- $args : array
Tags
Return values
mixedpageInfo()
Renders a page displaying a role's information, in read-only mode.
public
pageInfo(
$request :
ServerRequestInterface
, $response :
ResponseInterface
, $args :
array
)
: mixed
This checks that the currently logged-in user has permission to view the requested role's info. It checks each field individually, showing only those that you have permission to view. This will also try to show buttons for deleting and editing the role. This page requires authentication.
Request type: GET
Parameters
- $request : ServerRequestInterface
- $response : ResponseInterface
- $args : array
Tags
Return values
mixedpageList()
Renders the role listing page.
public
pageList(
$request :
ServerRequestInterface
, $response :
ResponseInterface
, $args :
array
)
: mixed
This page renders a table of roles, with dropdown menus for admin actions for each role. Actions typically include: edit role, delete role. This page requires authentication.
Request type: GET
Parameters
- $request : ServerRequestInterface
- $response : ResponseInterface
- $args : array
Tags
Return values
mixedupdateInfo()
Processes the request to update an existing role's details.
public
updateInfo(
$request :
ServerRequestInterface
, $response :
ResponseInterface
, $args :
array
)
: mixed
Processes the request from the role update form, checking that:
- The role name/slug are not already in use;
- The user has the necessary permissions to update the posted field(s);
- The submitted data is valid. This route requires authentication (and should generally be limited to admins or the root user).
Request type: PUT
Parameters
- $request : ServerRequestInterface
- $response : ResponseInterface
- $args : array
Tags
Return values
mixedupdateField()
Processes the request to update a specific field for an existing role, including permissions.
public
updateField(
$request :
ServerRequestInterface
, $response :
ResponseInterface
, $args :
array
)
: mixed
Processes the request from the role update form, checking that:
- The logged-in user has the necessary permissions to update the putted field(s);
- The submitted data is valid. This route requires authentication.
Request type: PUT
Parameters
- $request : ServerRequestInterface
- $response : ResponseInterface
- $args : array
Tags
Return values
mixedgetRoleFromParams()
Get role instance from params.
protected
getRoleFromParams(
$params :
array
)
: Role
Parameters
- $params : array
Tags
Return values
Role__construct()
Constructor.
public
__construct(
$ci :
ContainerInterface
)
: mixed
Parameters
- $ci : ContainerInterface
The global container object, which holds all your services.