Documentation

ContextBase
in package
Uses Singleton

A class that stores various useful pieces of data for access throughout the rest of the system.

Table of Contents

$contexts  : array<, OODBBean>
$getters  : array<, Base>
$instance  : object
The only instance of using class
$luser  : OODBBean|null
$ons  : array<, array<, string>>
$reqaction  : string
$reqrest  : array<, string>
$roles  : array<, OODBBean>
$tokenAuth  : bool
action()  : string
Return the main action part of the URL as set by .htaccess
formData()  : object
Return a Formdata object
getinstance()  : object
Checks, instantiates and returns the only instance of the using class.
getOns()  : string
Get the JS for onloading the ons
hasToken()  : bool
Find out if this was validated using a token, if so, it is coming from a device not a browser
hasUser()  : bool
Do we have a logged in user?
load()  : OODBBean
Load a bean
local()  : Local
Return the local object
rest()  : array<, string>
Return the part of the URL after the main action as set by .htaccess
roleContext()  : OODBBean
Find a rolecontext bean
roleName()  : OODBBean
Find a rolename bean
saveOn()  : void
Save values into the on cache
setup()  : ContextBase
Initialise the context and return self
user()  : OODBBean|null
Return the current logged in user if any
web()  : Web
Return the Web object

Properties

$contexts

protected array<, OODBBean> $contexts = []

A cache for rolecontext beans

$instance

The only instance of using class

protected static object $instance = NULL

$luser

protected OODBBean|null $luser = NULL

NULL or an object decribing the current logged in User (if we have logins at all)

$ons

protected array<, array<, string>> $ons = []

A cache for JS ons

$reqaction

protected string $reqaction = 'home'

The first component of the current URL

$reqrest

protected array<, string> $reqrest = []

The rest of the current URL exploded at /

$roles

protected array<, OODBBean> $roles = []

A cache for rolename beans

$tokenAuth

protected bool $tokenAuth = FALSE

True if authenticated by token

Methods

action()

Return the main action part of the URL as set by .htaccess

public action() : string
Return values
string

formData()

Return a Formdata object

public formData([string|null $which = NULL ]) : object
Parameters
$which : string|null = NULL
Tags
psalm-suppress

LessSpecificReturnStatement

psalm-suppress

MoreSpecificReturnType

Return values
object

getinstance()

Checks, instantiates and returns the only instance of the using class.

public static getinstance() : object
Tags
template

object

psalm-return

object

psalm-suppress

MismatchingDocblockReturnType

psalm-suppress

ReservedWord

Return values
object

getOns()

Get the JS for onloading the ons

public getOns() : string
Tags
psalm-suppress

PossiblyUnusedMethod

phpcsSuppress

PhpCs.StringNotation.SingleQuoteFixer

Return values
string

hasToken()

Find out if this was validated using a token, if so, it is coming from a device not a browser

public hasToken() : bool
Return values
bool

hasUser()

Do we have a logged in user?

public hasUser() : bool
Return values
bool

load()

Load a bean

public load(string $bean, int $id[, bool $forupdate = FALSE ]) : OODBBean
Parameters
$bean : string

A bean type name

$id : int

A bean id

$forupdate : bool = FALSE

If TRUE then use loadforupdate

R::load returns a new bean with id 0 if the given id does not exist.

Tags
throws
MissingBean
throws
InvalidArgumentException
  • this would be an internal error
Return values
OODBBean

local()

Return the local object

public local() : Local
Tags
psalm-suppress

MoreSpecificReturnType

psalm-suppress

LessSpecificReturnStatement

psalm-suppress

MoreSpecificReturnType

Return values
Local

rest()

Return the part of the URL after the main action as set by .htaccess

public rest() : array<, string>

See setup() below for how the URL is processed to create the result array.

Note that if there is nothing after the action in the URL this function returns an array with a single element containing an empty string.

Return values
array<, string>

roleContext()

Find a rolecontext bean

public roleContext(string $name) : OODBBean
Parameters
$name : string

A Role Context

Tags
throws
InternalError
psalm-suppress

PossiblyUnusedMethod

Return values
OODBBean

roleName()

Find a rolename bean

public roleName(string $name) : OODBBean
Parameters
$name : string

A Role name

Tags
throws
InternalError
psalm-suppress

PossiblyUnusedMethod

Return values
OODBBean

saveOn()

Save values into the on cache

public saveOn(string $id, string $on, string $fn) : void
Parameters
$id : string
$on : string
$fn : string
Tags
psalm-suppress

PossiblyUnusedMethod

Return values
void

user()

Return the current logged in user if any

public user() : OODBBean|null
Return values
OODBBean|null

web()

Return the Web object

public web() : Web
Tags
psalm-suppress

LessSpecificReturnStatement

psalm-suppress

MoreSpecificReturnType

Return values
Web

Search results