Documentation

CRM_Utils_Recent
in package

Recent items utility class.

Table of Contents

Constants

MAX_ITEMS  = 30
Max number of recent items to store
STORE_NAME  = 'CRM_Utils_Recent'
Store name

Properties

$_maxItems  : int
Maximum stack size
$_recent  : array<string|int, mixed>
The list of recently viewed items.

Methods

add()  : mixed
Add an item to the recent stack.
create()  : mixed
Create function used by the API - supplies defaults
del()  : mixed
Delete item(s) from the recently-viewed list.
delContact()  : mixed
Delete an item from the recent stack.
get()  : array<string|int, mixed>
Return the recently viewed array.
getProviders()  : array<string|int, mixed>
Gets the list of available providers to civi's recent items stack
initialize()  : mixed
Initialize this class and set the static variables.
isProviderEnabled()  : bool
Check if a provider is allowed to add stuff.
on_hook_civicrm_post()  : mixed
Callback for hook_civicrm_post().
getIcon()  : string|null
getTitle()  : string|null
Get default title for this item, based on the entity's `label_field`
getTokens()  : array<string|int, mixed>
Get a list of square-bracket tokens from a path string
getUrl()  : string|null
Get a link to view/update/delete a given entity.
normalizeEntityType()  : string
removeItems()  : mixed
Remove items from the array that match given props

Constants

MAX_ITEMS

Max number of recent items to store

public int MAX_ITEMS = 30

STORE_NAME

Store name

public string STORE_NAME = 'CRM_Utils_Recent'

Properties

$_maxItems

Maximum stack size

private static int $_maxItems = 10

$_recent

The list of recently viewed items.

private static array<string|int, mixed> $_recent = \NULL

Methods

add()

Add an item to the recent stack.

public static add(string $title, string $url, string $entityId, string $entityType, int $contactId, string $contactName[, array<string|int, mixed> $others = [] ]) : mixed
Parameters
$title : string

The title to display.

$url : string

The link for the above title.

$entityId : string

Object id.

$entityType : string
$contactId : int

Deprecated, probably unused param

$contactName : string

Deprecated, probably unused param

$others : array<string|int, mixed> = []

create()

Create function used by the API - supplies defaults

public static create(array<string|int, mixed> $params, AbstractAction $action) : mixed
Parameters
$params : array<string|int, mixed>
$action : AbstractAction

del()

Delete item(s) from the recently-viewed list.

public static del(array<string|int, mixed> $removeItem) : mixed
Parameters
$removeItem : array<string|int, mixed>

Item to be removed.

delContact()

Delete an item from the recent stack.

public static delContact(string $id) : mixed
Parameters
$id : string

get()

Return the recently viewed array.

public static & get() : array<string|int, mixed>
Return values
array<string|int, mixed>

the recently viewed array

getProviders()

Gets the list of available providers to civi's recent items stack

public static getProviders() : array<string|int, mixed>
Return values
array<string|int, mixed>

initialize()

Initialize this class and set the static variables.

public static initialize() : mixed

isProviderEnabled()

Check if a provider is allowed to add stuff.

public static isProviderEnabled(string $providerName) : bool

If corresponding setting is empty, all are allowed

Parameters
$providerName : string
Return values
bool

on_hook_civicrm_post()

Callback for hook_civicrm_post().

public static on_hook_civicrm_post(PostEvent $event) : mixed
Parameters
$event : PostEvent

getIcon()

private static getIcon(mixed $entityType, mixed $entityId) : string|null
Parameters
$entityType : mixed
$entityId : mixed
Return values
string|null

getTitle()

Get default title for this item, based on the entity's `label_field`

private static getTitle(string $entityType, int $entityId) : string|null
Parameters
$entityType : string
$entityId : int
Return values
string|null

getTokens()

Get a list of square-bracket tokens from a path string

private static getTokens(string $str) : array<string|int, mixed>
Parameters
$str : string
Return values
array<string|int, mixed>

getUrl()

Get a link to view/update/delete a given entity.

private static getUrl(string $entityType, int $entityId, string $action) : string|null
Parameters
$entityType : string
$entityId : int
$action : string

Either 'view', 'update', or 'delete'

Return values
string|null

normalizeEntityType()

private static normalizeEntityType(string $entityType) : string
Parameters
$entityType : string
Return values
string

removeItems()

Remove items from the array that match given props

private static removeItems(array<string|int, mixed> $props) : mixed
Parameters
$props : array<string|int, mixed>

        
On this page

Search results