UserFrosting API

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
author

Alex Weissman (https://alexanderweissman.com)

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

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:

  1. The role name and slug are not already in use;
  2. The user has permission to create a new role;
  3. 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
see
getModalCreateRole
throws
ForbiddenException

If user is not authozied to access page

Return values
mixed

delete()

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:

  1. The user has permission to delete this role;
  2. The role is not a default for new users;
  3. The role does not have any associated users;
  4. 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
throws
NotFoundException

If role is not found

throws
ForbiddenException

If user is not authozied to access page

throws
BadRequestException
Return values
mixed

getInfo()

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
throws
ForbiddenException

If user is not authozied to access page

throws
NotFoundException

If role is not found

Return values
mixed

getList()

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
throws
ForbiddenException

If user is not authozied to access page

Return values
mixed

getModalConfirmDelete()

Display deletion confirmation modal.

public getModalConfirmDelete( $request : ServerRequestInterface , $response : ResponseInterface , $args : array ) : mixed
Parameters
$request : ServerRequestInterface
$response : ResponseInterface
$args : array
Tags
throws
NotFoundException

If role is not found

throws
ForbiddenException

If user is not authozied to access page

throws
BadRequestException
Return values
mixed

getModalCreate()

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
throws
ForbiddenException

If user is not authozied to access page

Return values
mixed

getModalEdit()

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
throws
NotFoundException

If role is not found

throws
ForbiddenException

If user is not authozied to access page

Return values
mixed

getModalEditPermissions()

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
throws
NotFoundException

If role is not found

throws
ForbiddenException

If user is not authozied to access page

Return values
mixed

getPermissions()

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
throws
NotFoundException

If role is not found

throws
ForbiddenException

If user is not authozied to access page

Return values
mixed

getUsers()

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
throws
NotFoundException

If role is not found

throws
ForbiddenException

If user is not authozied to access page

Return values
mixed

pageInfo()

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
throws
ForbiddenException

If user is not authozied to access page

Return values
mixed

pageList()

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
throws
ForbiddenException

If user is not authozied to access page

Return values
mixed

updateInfo()

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:

  1. The role name/slug are not already in use;
  2. The user has the necessary permissions to update the posted field(s);
  3. 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
see
getModalRoleEdit
throws
NotFoundException

If role is not found

throws
ForbiddenException

If user is not authozied to access page

Return values
mixed

updateField()

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:

  1. The logged-in user has the necessary permissions to update the putted field(s);
  2. The submitted data is valid. This route requires authentication.

Request type: PUT

Parameters
$request : ServerRequestInterface
$response : ResponseInterface
$args : array
Tags
throws
NotFoundException

If role is not found

throws
ForbiddenException

If user is not authozied to access page

throws
BadRequestException
Return values
mixed

__construct()

Constructor.

public __construct( $ci : ContainerInterface ) : mixed
Parameters
$ci : ContainerInterface

The global container object, which holds all your services.

Return values
mixed

Search results