CodeIgniter Extension

Access
in package

Access control attribute for controller methods.

Define access permissions for controller methods based on login state, user role, and request type.

Usage:

use X\Annotation\Access;

#[Access(allow_login: true, allow_logoff: false, allow_role: "admin,user")]
public function dashboard() }

Table of Contents

Properties

$allow_http  : bool
Allow access from HTTP requests.
$allow_login  : bool
Allow access for logged-in users.
$allow_logoff  : bool
Allow access for logged-off (guest) users.
$allow_role  : string
Allowed role names for logged-in users.

Methods

__construct()  : mixed
Initialize access control settings.

Properties

$allow_http

Allow access from HTTP requests.

public bool $allow_http = true

Set to false to restrict access to CLI only.

Set to true to allow HTTP access, false for CLI only.

$allow_login

Allow access for logged-in users.

public bool $allow_login = true

Set to true to allow, false to deny.

$allow_logoff

Allow access for logged-off (guest) users.

public bool $allow_logoff = true

Set to true to allow, false to deny.

$allow_role

Allowed role names for logged-in users.

public string $allow_role = ''

Multiple roles can be specified with comma separation (e.g., "admin,editor,user"). Empty string means all roles are allowed.

Comma-separated role names.

Methods

__construct()

Initialize access control settings.

public __construct([bool $allow_login = true ][, bool $allow_logoff = true ][, string $allow_role = '' ][, bool $allow_http = true ]) : mixed
Parameters
$allow_login : bool = true

Allow access for logged-in users. Default is true.

$allow_logoff : bool = true

Allow access for logged-off (guest) users. Default is true.

$allow_role : string = ''

Comma-separated role names allowed for logged-in users. Empty string means all roles. Default is "".

$allow_http : bool = true

Allow access from HTTP requests. Set to false for CLI only. Default is true.


        
On this page

Search results