Tripal
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
Drupal\tripal\TripalField\TripalFormatterBase Class Reference
Inheritance diagram for Drupal\tripal\TripalField\TripalFormatterBase:
Inheritance graph
[legend]
Collaboration diagram for Drupal\tripal\TripalField\TripalFormatterBase:
Collaboration graph
[legend]

Public Member Functions

 sanitizeKey ($key)
 
 createListMarkup (array $list)
 
 addMaxDeltaWarning (array &$elements, array &$list, ?array $markup=NULL)
 

Public Attributes

int $max_delta = 100
 

Detailed Description

Defines the Tripal field formatter base class.

Member Function Documentation

◆ addMaxDeltaWarning()

Drupal\tripal\TripalField\TripalFormatterBase::addMaxDeltaWarning ( array &  $elements,
array &  $list,
?array  $markup = NULL 
)

Provides a visible warning message when max_delta has been exceeded.

Parameters
array&$elementsThe render array elements.
array&$listThe viewElements to be formatted. The list size may exceed max_delta by one, this is the indicator to display the message, and this last element will be removed.
array | null$markupCustom render array markup to override the default message.
Returns
void &$elements is modified when appropriate

◆ createListMarkup()

Drupal\tripal\TripalField\TripalFormatterBase::createListMarkup ( array  $list)

HELPER: Makes multiple renderable items into a list.

Note: If the number of items exceeds the max delta for this field, then a warning will be added right before the list.

Parameters
array$listA list of renderable items.
Returns
array A render array where (1) if no items then an empty element is returned, (2) if there is one item it is passed through unchanged, (3) if $items <= $max_delta then a list of items is returned, (4) if $items > $max_delta then two elements are returned where the first is a warning string and the second is a list of items.

◆ sanitizeKey()

Drupal\tripal\TripalField\TripalFormatterBase::sanitizeKey (   $key)

Sanitizes a property key.

Property keys are often controlled vocabulary IDs, which is the IdSpace and accession separated by a colon. The colon is not supported by the storage backend and must be converted to an underscore. This function performs that task.

Parameters
string$keyA property key e.g. "operation:2945".
Returns
string A sanitizied string.

The documentation for this class was generated from the following file: