CRM_Core_CommunityMessages
in package
Manage the download, validation, and rendering of community messages
Table of Contents
Constants
- DEFAULT_MESSAGES_URL = 'https://alert.civicrm.org/alert?prot=1&ver={ver}&uf={uf}&sid={sid}&lang={lang}&co={co}'
- DEFAULT_PERMISSION = 'administer CiviCRM'
- DEFAULT_RETRY = 7200
- Default time to wait before retrying.
Properties
- $cache : CRM_Utils_Cache_Interface
- $client : CRM_Utils_HttpClient
- $messagesUrl : false|string
- Url to retrieve community messages from.
Methods
- __construct() : mixed
- Class constructor.
- create() : CRM_Core_CommunityMessages
- Create default instance.
- evalMarkup() : string
- fetchDocument() : null|array<string|int, mixed>
- Download document from URL and parse as JSON.
- getDocument() : null|array<string|int, mixed>
- Get the messages document (either from the cache or by downloading).
- getRenderedUrl() : false|string
- Get the final, usable URL string (after interpolating any variables)
- isEnabled() : bool
- pick() : null|array<string|int, mixed>
- Pick a message to display.
- validateDocument() : bool
- Ensure that a document is well-formed
Constants
DEFAULT_MESSAGES_URL
public
mixed
DEFAULT_MESSAGES_URL
= 'https://alert.civicrm.org/alert?prot=1&ver={ver}&uf={uf}&sid={sid}&lang={lang}&co={co}'
DEFAULT_PERMISSION
public
mixed
DEFAULT_PERMISSION
= 'administer CiviCRM'
DEFAULT_RETRY
Default time to wait before retrying.
public
mixed
DEFAULT_RETRY
= 7200
Properties
$cache
protected
CRM_Utils_Cache_Interface
$cache
$client
protected
CRM_Utils_HttpClient
$client
$messagesUrl
Url to retrieve community messages from.
protected
false|string
$messagesUrl
False means a retrieval will not be attempted.
Methods
__construct()
Class constructor.
public
__construct(CRM_Utils_Cache_Interface $cache, CRM_Utils_HttpClient $client[, string|false $messagesUrl = NULL ]) : mixed
Parameters
- $cache : CRM_Utils_Cache_Interface
- $client : CRM_Utils_HttpClient
- $messagesUrl : string|false = NULL
create()
Create default instance.
public
static create() : CRM_Core_CommunityMessages
Return values
CRM_Core_CommunityMessagesevalMarkup()
public
static evalMarkup(string $markup) : string
Parameters
- $markup : string
Return values
stringfetchDocument()
Download document from URL and parse as JSON.
public
fetchDocument() : null|array<string|int, mixed>
Return values
null|array<string|int, mixed> —parsed JSON
getDocument()
Get the messages document (either from the cache or by downloading).
public
getDocument() : null|array<string|int, mixed>
Return values
null|array<string|int, mixed>getRenderedUrl()
Get the final, usable URL string (after interpolating any variables)
public
getRenderedUrl() : false|string
Return values
false|stringisEnabled()
public
isEnabled() : bool
Return values
boolpick()
Pick a message to display.
public
pick() : null|array<string|int, mixed>
Return values
null|array<string|int, mixed>validateDocument()
Ensure that a document is well-formed
public
validateDocument(array<string|int, mixed> $document) : bool
Parameters
- $document : array<string|int, mixed>