abstract class Key extends ConcreteObject (View source)

Constants

ACCESS_TYPE_INCLUDE

Access type: inclusive.

ACCESS_TYPE_EXCLUDE

Access type: exclusive.

ACCESS_TYPE_ALL

Access type: any.

Properties

$error from  ConcreteObject
protected ObjectInterface|null $permissionObject

The object for which this permission is for (for example, a Page instance).

bool|int|string $pkID
string $pkName
string $pkHandle
string $pkDescription
bool|int|string $pkCategoryID
string $pkCategoryHandle
bool|int|string|null $pkgID
bool|int|string $pkCanTriggerWorkflow
bool|int|string $pkHasCustomClass
ObjectInterface|null $permissionObjectToCheck

Methods

loadError($error)

No description

isError()

No description

getError()

No description

setPropertiesFromArray($arr)

No description

static 
camelcase($file)

No description

static 
uncamelcase($string)

No description

array
getSupportedAccessTypes()

Get the identifiers (keys) and descriptions (values) of the access types.

bool
canPermissionKeyTriggerWorkflow()

Returns whether a permission key can start a workflow.

bool
permissionKeyHasCustomClass()

Returns whether a permission key has a custom class.

string
getPermissionKeyName()

Returns the name for this permission key.

string
getPermissionKeyDisplayName(string $format = 'html')

Returns the display name for this permission key (localized and escaped accordingly to $format).

string
getPermissionKeyHandle()

Returns the handle for this permission key.

string
getPermissionKeyDescription()

Returns the description for this permission key.

string
getPermissionKeyDisplayDescription(string $format = 'html')

Returns the display description for this permission key (localized and escaped accordingly to $format).

int
getPermissionKeyID()

Returns the ID for this permission key.

int
getPermissionKeyCategoryID()

Returns the ID for the category of this permission key.

string
getPermissionKeyCategoryHandle()

Returns the handle for the category of this permission key.

setPermissionObject(ObjectInterface|null $object)

Set the object for which this permission is for (for example, a Page instance).

getPermissionObjectToCheck()

Set the actual object that should be checked for this permission (for example, a Page instance).

getPermissionObject()

Get the object for which this permission is for (for example, a Page instance).

static Key[]
loadAll()

Get the list of all the defined permission keys.

bool
hasCustomOptionsForm()

Does this permission key have a form (located at elements/permission/keys/.php)?

int|null
getPackageID()

Get the ID of the package that defines this permission key.

string|null
getPackageHandle()

Get the handle of the package that defines this permission key.

static Key[]
getList(string $pkCategoryHandle, array $filters = [])

Returns the list of all permissions of this category.

export(SimpleXMLElement $axml)

Export this permission key to a SimpleXMLElement instance.

static 
exportList(SimpleXMLElement $xml)

Export the list of all permissions of this category to a SimpleXMLElement instance.

static Key[]
getListByPackage(Package|Package $pkg)

Get the list of permission keys defined by a package.

static Key
import(SimpleXMLElement $pk)

Import a permission key from a SimpleXMLElement element.

static Key|null
getByID(int $pkID)

Get a permission key given its ID.

static Key|null
getByHandle(string $pkHandle)

Get a permission key given its handle.

static 
add(string $pkCategoryHandle, string $pkHandle, string $pkName, string $pkDescription, bool $pkCanTriggerWorkflow, bool $pkHasCustomClass, Package|Package|null $pkg = false)

Adds an permission key.

setPermissionKeyHasCustomClass(bool $pkHasCustomClass)

Mark this permission key as having (or not) a custom class.

can() deprecated

No description

bool
validate()

Check if the current user is of for this key and its current permission object (if any).

delete()

Delete this permission key.

getAccessListItems()

A shortcut for grabbing the current assignment and passing into that object.

Access|null
getPermissionAccessObject()

No description

int|null
getPermissionAccessID()

No description

exportAccess(SimpleXMLElement $pxml)

No description

static Translations
exportTranslations()

Export the strings that should be translated.

static Key|null
load(int|mixed $key, string $loadBy = 'pkID')

Load a permission key by its ID (or whatever is passed to $loadBy).

Details

loadError($error)

No description

Parameters

$error

isError()

No description

getError()

No description

setPropertiesFromArray($arr)

No description

Parameters

$arr

static camelcase($file)

No description

Parameters

$file

static uncamelcase($string)

No description

Parameters

$string

array getSupportedAccessTypes()

Get the identifiers (keys) and descriptions (values) of the access types.

Return Value

array

bool canPermissionKeyTriggerWorkflow()

Returns whether a permission key can start a workflow.

Return Value

bool

bool permissionKeyHasCustomClass()

Returns whether a permission key has a custom class.

Return Value

bool

string getPermissionKeyName()

Returns the name for this permission key.

Return Value

string

string getPermissionKeyDisplayName(string $format = 'html')

Returns the display name for this permission key (localized and escaped accordingly to $format).

Parameters

string $format

= 'html' Escape the result in html format (if $format is 'html'). If $format is 'text' or any other value, the display name won't be escaped.

Return Value

string

string getPermissionKeyHandle()

Returns the handle for this permission key.

Return Value

string

string getPermissionKeyDescription()

Returns the description for this permission key.

Return Value

string

string getPermissionKeyDisplayDescription(string $format = 'html')

Returns the display description for this permission key (localized and escaped accordingly to $format).

Parameters

string $format

= 'html' Escape the result in html format (if $format is 'html'). If $format is 'text' or any other value, the display description won't be escaped.

Return Value

string

int getPermissionKeyID()

Returns the ID for this permission key.

Return Value

int

int getPermissionKeyCategoryID()

Returns the ID for the category of this permission key.

Return Value

int

string getPermissionKeyCategoryHandle()

Returns the handle for the category of this permission key.

Return Value

string

setPermissionObject(ObjectInterface|null $object)

Set the object for which this permission is for (for example, a Page instance).

Parameters

ObjectInterface|null $object

getPermissionObjectToCheck()

Set the actual object that should be checked for this permission (for example, a Page instance).

ObjectInterface|null getPermissionObject()

Get the object for which this permission is for (for example, a Page instance).

Return Value

ObjectInterface|null

static Key[] loadAll()

Get the list of all the defined permission keys.

Return Value

Key[]

bool hasCustomOptionsForm()

Does this permission key have a form (located at elements/permission/keys/.php)?

Return Value

bool

int|null getPackageID()

Get the ID of the package that defines this permission key.

Return Value

int|null

string|null getPackageHandle()

Get the handle of the package that defines this permission key.

Return Value

string|null

static Key[] getList(string $pkCategoryHandle, array $filters = [])

Returns the list of all permissions of this category.

Parameters

string $pkCategoryHandle
array $filters

An array containing of field name => value (to be used directly in the SQL query)

Return Value

Key[]

SimpleXMLElement export(SimpleXMLElement $axml)

Export this permission key to a SimpleXMLElement instance.

Parameters

SimpleXMLElement $axml

Return Value

SimpleXMLElement

static exportList(SimpleXMLElement $xml)

Export the list of all permissions of this category to a SimpleXMLElement instance.

Parameters

SimpleXMLElement $xml

static Key[] getListByPackage(Package|Package $pkg)

Get the list of permission keys defined by a package.

Note, this queries both the pkgID found on the PermissionKeys table AND any permission keys of a special type installed by that package, and any in categories by that package.

Parameters

Package|Package $pkg

Return Value

Key[]

static Key import(SimpleXMLElement $pk)

Import a permission key from a SimpleXMLElement element.

Parameters

SimpleXMLElement $pk

Return Value

Key

static Key|null getByID(int $pkID)

Get a permission key given its ID.

Parameters

int $pkID

Return Value

Key|null

static Key|null getByHandle(string $pkHandle)

Get a permission key given its handle.

Parameters

string $pkHandle

Return Value

Key|null

static add(string $pkCategoryHandle, string $pkHandle, string $pkName, string $pkDescription, bool $pkCanTriggerWorkflow, bool $pkHasCustomClass, Package|Package|null $pkg = false)

Adds an permission key.

Parameters

string $pkCategoryHandle
string $pkHandle
string $pkName
string $pkDescription
bool $pkCanTriggerWorkflow
bool $pkHasCustomClass
Package|Package|null $pkg

setPermissionKeyHasCustomClass(bool $pkHasCustomClass)

Mark this permission key as having (or not) a custom class.

Parameters

bool $pkHasCustomClass

can() deprecated

deprecated use the validate() method

No description

bool validate()

Check if the current user is of for this key and its current permission object (if any).

Return Value

bool

delete()

Delete this permission key.

ListItem[] getAccessListItems()

A shortcut for grabbing the current assignment and passing into that object.

Return Value

ListItem[]

Assignment getPermissionAssignmentObject()

No description

Return Value

Assignment

Access|null getPermissionAccessObject()

No description

Return Value

Access|null

int|null getPermissionAccessID()

No description

Return Value

int|null

exportAccess(SimpleXMLElement $pxml)

No description

Parameters

SimpleXMLElement $pxml

static Translations exportTranslations()

Export the strings that should be translated.

Return Value

Translations

static protected Key|null load(int|mixed $key, string $loadBy = 'pkID')

Load a permission key by its ID (or whatever is passed to $loadBy).

Parameters

int|mixed $key

the ID (or the value of the $loadBy field) of the key to be loaded

string $loadBy

the field to be used to locate the permission key

Return Value

Key|null