Drupal 8  8.0.2
FieldPluginBase Class Reference
Inheritance diagram for FieldPluginBase:

Public Member Functions

 init (ViewExecutable $view, DisplayPluginBase $display, array &$options=NULL)
 
 query ()
 
 clickSort ($order)
 
 clickSortable ()
 
 label ()
 
 elementType ($none_supported=FALSE, $default_empty=FALSE, $inline=FALSE)
 
 elementLabelType ($none_supported=FALSE, $default_empty=FALSE)
 
 elementWrapperType ($none_supported=FALSE, $default_empty=FALSE)
 
 getElements ()
 
 elementClasses ($row_index=NULL)
 
 tokenizeValue ($value, $row_index=NULL)
 
 elementLabelClasses ($row_index=NULL)
 
 elementWrapperClasses ($row_index=NULL)
 
 getEntity (ResultRow $values)
 
 getValue (ResultRow $values, $field=NULL)
 
 useStringGroupBy ()
 
 submitOptionsForm (&$form, FormStateInterface $form_state)
 
 buildOptionsForm (&$form, FormStateInterface $form_state)
 
 adminSummary ()
 
 preRender (&$values)
 
 render (ResultRow $values)
 
 postRender (ResultRow $row, $output)
 
 advancedRender (ResultRow $values)
 
 isValueEmpty ($value, $empty_zero, $no_skip_empty=TRUE)
 
 renderText ($alter)
 
 theme (ResultRow $values)
 
 themeFunctions ()
 
 adminLabel ($short=FALSE)
 
- Public Member Functions inherited from HandlerBase
 __construct (array $configuration, $plugin_id, $plugin_definition)
 
 init (ViewExecutable $view, DisplayPluginBase $display, array &$options=NULL)
 
 adminLabel ($short=FALSE)
 
 getField ($field=NULL)
 
 sanitizeValue ($value, $type=NULL)
 
 buildOptionsForm (&$form, FormStateInterface $form_state)
 
 setModuleHandler (ModuleHandlerInterface $module_handler)
 
 usesGroupBy ()
 
 buildGroupByForm (&$form, FormStateInterface $form_state)
 
 submitGroupByForm (&$form, FormStateInterface $form_state)
 
 hasExtraOptions ()
 
 defineExtraOptions (&$option)
 
 buildExtraOptionsForm (&$form, FormStateInterface $form_state)
 
 validateExtraOptionsForm ($form, FormStateInterface $form_state)
 
 submitExtraOptionsForm ($form, FormStateInterface $form_state)
 
 canExpose ()
 
 defaultExposeOptions ()
 
 exposedInfo ()
 
 buildExposedForm (&$form, FormStateInterface $form_state)
 
 validateExposed (&$form, FormStateInterface $form_state)
 
 submitExposed (&$form, FormStateInterface $form_state)
 
 buildExposeForm (&$form, FormStateInterface $form_state)
 
 validateExposeForm ($form, FormStateInterface $form_state)
 
 submitExposeForm ($form, FormStateInterface $form_state)
 
 showExposeButton (&$form, FormStateInterface $form_state)
 
 showExposeForm (&$form, FormStateInterface $form_state)
 
 access (AccountInterface $account)
 
 preQuery ()
 
 query ()
 
 postExecute (&$values)
 
 setRelationship ()
 
 ensureMyTable ()
 
 adminSummary ()
 
 isExposed ()
 
 isAGroup ()
 
 multipleExposedInput ()
 
 acceptExposedInput ($input)
 
 storeExposedInput ($input, $status)
 
 getJoin ()
 
 validate ()
 
 broken ()
 
 getDateFormat ($format)
 
 getDateField ()
 
 setViewsData (ViewsData $views_data)
 
 getEntityType ()
 
 displayExposedForm ($form, FormStateInterface $form_state)
 
 submitTemporaryForm ($form, FormStateInterface $form_state)
 
- Public Member Functions inherited from PluginBase
 __construct (array $configuration, $plugin_id, $plugin_definition)
 
 init (ViewExecutable $view, DisplayPluginBase $display, array &$options=NULL)
 
 filterByDefinedOptions (array &$storage)
 
 unpackOptions (&$storage, $options, $definition=NULL, $all=TRUE, $check=TRUE)
 
 destroy ()
 
 buildOptionsForm (&$form, FormStateInterface $form_state)
 
 validateOptionsForm (&$form, FormStateInterface $form_state)
 
 submitOptionsForm (&$form, FormStateInterface $form_state)
 
 query ()
 
 themeFunctions ()
 
 validate ()
 
 summaryTitle ()
 
 pluginTitle ()
 
 usesOptions ()
 
 globalTokenReplace ($string= '', array $options=array())
 
 getAvailableGlobalTokens ($prepared=FALSE, array $types=array())
 
 globalTokenForm (&$form, FormStateInterface $form_state)
 
 calculateDependencies ()
 
 getProvider ()
 
- Public Member Functions inherited from PluginInspectionInterface
 getPluginId ()
 
 getPluginDefinition ()
 
- Public Member Functions inherited from DerivativeInspectionInterface
 getBaseId ()
 
 getDerivativeId ()
 
- Public Member Functions inherited from FieldHandlerInterface
 getRenderTokens ($item)
 

Static Public Member Functions

static trimText ($alter, $value)
 
- Static Public Member Functions inherited from HandlerBase
static getTableJoin ($table, $base_table)
 
static breakString ($str, $force_int=FALSE)
 
- Static Public Member Functions inherited from PluginBase
static create (ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition)
 
static preRenderAddFieldsetMarkup (array $form)
 
static preRenderFlattenData ($form)
 
static queryLanguageSubstitutions ()
 

Data Fields

const RENDER_TEXT_PHASE_SINGLE_ITEM = 0
 
const RENDER_TEXT_PHASE_COMPLETELY = 1
 
const RENDER_TEXT_PHASE_EMPTY = 2
 
 $field_alias = 'unknown'
 
 $aliases = array()
 
 $original_value = NULL
 
 $additional_fields = array()
 
- Data Fields inherited from HandlerBase
 $query = NULL
 
 $table
 
 $tableAlias
 
 $actualTable
 
 $realField
 
 $field
 
 $actualField
 
 $relationship = NULL
 
- Data Fields inherited from PluginBase
const INCLUDE_NEGOTIATED = 16
 
const INCLUDE_ENTITY = 32
 
const VIEWS_QUERY_LANGUAGE_SITE_DEFAULT = '***LANGUAGE_site_default***'
 
 $options = array()
 
 $view = NULL
 
 $displayHandler
 
 $definition
 

Protected Member Functions

 allowAdvancedRender ()
 
 addAdditionalFields ($fields=NULL)
 
 defineOptions ()
 
 getPreviousFieldLabels ()
 
 renderAltered ($alter, $tokens)
 
 renderTrimText ($alter, $value)
 
 renderAsLink ($alter, $text, $tokens)
 
 getFieldTokenPlaceholder ()
 
 getTokenValuesRecursive (array $array, array $parent_keys=array())
 
 addSelfTokens (&$tokens, $item)
 
 documentSelfTokens (&$tokens)
 
 linkGenerator ()
 
 getRenderer ()
 
- Protected Member Functions inherited from HandlerBase
 defineOptions ()
 
 caseTransform ($string, $option)
 
 getModuleHandler ()
 
 placeholder ()
 
 getViewsData ()
 
- Protected Member Functions inherited from PluginBase
 defineOptions ()
 
 setOptionDefaults (array &$storage, array $options)
 
 doFilterByDefinedOptions (array &$storage, array $options)
 
 viewsTokenReplace ($text, $tokens)
 
 listLanguages ($flags=LanguageInterface::STATE_ALL, array $current_values=NULL)
 
 getRenderer ()
 

Protected Attributes

 $linkGenerator
 
 $renderer
 
- Protected Attributes inherited from HandlerBase
 $moduleHandler
 
 $viewsData
 
- Protected Attributes inherited from PluginBase
 $usesOptions = FALSE
 
 $renderer
 

Detailed Description

Base class for views fields.

Member Function Documentation

addAdditionalFields (   $fields = NULL)
protected

Add 'additional' fields to the query.

Parameters
$fieldsAn array of fields. The key is an identifier used to later find the field alias used. The value is either a string in which case it's assumed to be a field on this handler's table; or it's an array in the form of
array('table' => $tablename, 'field' => $fieldname)

References FieldPluginBase\query(), and t().

Referenced by Path\query(), Roles\query(), Permissions\query(), NodeNewComments\query(), LinkBase\query(), TaxonomyIndexTid\query(), FieldPluginBase\query(), and Field\query().

Here is the call graph for this function:

Here is the caller graph for this function:

addSelfTokens ( $tokens,
  $item 
)
protected

Add any special tokens this field might use for itself.

This method is intended to be overridden by items that generate fields as a list. For example, the field that displays all terms on a node might have tokens for the tid and the term.

By convention, tokens should follow the format of {{ token subtoken }} where token is the field ID and subtoken is the field. If the field ID is terms, then the tokens might be {{ terms__tid }} and {{ terms__name }}.

adminLabel (   $short = FALSE)

Return a string representing this handler's name in the UI.

Implements ViewsHandlerInterface.

adminSummary ( )

Provide extra data to the administration form

Implements ViewsHandlerInterface.

advancedRender ( ResultRow  $values)

{Renders a field using advanced settings.This renders a field normally, then decides if render-as-link and text-replacement rendering is necessary.

Parameters
\Drupal\views\ResultRow$valuesThe values retrieved from a single row of a view's query result.
Returns
string| The advanced rendered output. If the output is safe it will be wrapped in an object that implements MarkupInterface. If it is empty or unsafe it will be a string.
}

Implements FieldHandlerInterface.

allowAdvancedRender ( )
protected

Determine if this field can allow advanced rendering.

Fields can set this to FALSE if they do not wish to allow token based rewriting or link-making.

buildOptionsForm ( $form,
FormStateInterface  $form_state 
)

Default options form that provides the label widget that all fields should have.

Implements ViewsPluginInterface.

References t().

Here is the call graph for this function:

clickSort (   $order)

{Adds an ORDER BY clause to the query for click sort columns.

Parameters
string$orderEither ASC or DESC
}

Implements FieldHandlerInterface.

References FieldPluginBase\query().

Here is the call graph for this function:

clickSortable ( )

{Determines if this field is click sortable.

Returns
bool The value of 'click sortable' from the plugin definition, this defaults to TRUE if not set.
}

Implements FieldHandlerInterface.

documentSelfTokens ( $tokens)
protected

Document any special tokens this field might use for itself.

See Also
addSelfTokens()
elementClasses (   $row_index = NULL)

{Returns the class of the field.

Parameters
bool$row_indexThe index of current row.
}

Implements FieldHandlerInterface.

References Html\cleanCssIdentifier(), and FieldPluginBase\tokenizeValue().

Here is the call graph for this function:

elementLabelClasses (   $row_index = NULL)

{Returns the class of the field's label.

Parameters
bool$row_indexThe index of current row.
}

Implements FieldHandlerInterface.

References Html\cleanCssIdentifier(), and FieldPluginBase\tokenizeValue().

Here is the call graph for this function:

elementLabelType (   $none_supported = FALSE,
  $default_empty = FALSE 
)

{Returns an HTML element for the label based upon the field's element type.

Parameters
bool$none_supportedWhether or not this HTML element is supported.
bool$default_emptyWhether or not this HTML element is empty by default.
}

Implements FieldHandlerInterface.

elementType (   $none_supported = FALSE,
  $default_empty = FALSE,
  $inline = FALSE 
)

{Returns an HTML element based upon the field's element type.

Parameters
bool$none_supportedWhether or not this HTML element is supported.
bool$default_emptyWhether or not this HTML element is empty by default.
bool$inlineWhether or not this HTML element is inline.
}

Implements FieldHandlerInterface.

elementWrapperClasses (   $row_index = NULL)

{Returns the class of the field's wrapper.

Parameters
bool$row_indexThe index of current row.
}

Implements FieldHandlerInterface.

References Html\cleanCssIdentifier(), and FieldPluginBase\tokenizeValue().

Here is the call graph for this function:

elementWrapperType (   $none_supported = FALSE,
  $default_empty = FALSE 
)

{Returns an HTML element for the wrapper based upon the field's element type.

Parameters
bool$none_supportedWhether or not this HTML element is supported.
bool$default_emptyWhether or not this HTML element is empty by default.
}

Implements FieldHandlerInterface.

getElements ( )

{Provides a list of elements valid for field HTML.This function can be overridden by fields that want more or fewer elements available, though this seems like it would be an incredibly rare occurrence.}

Implements FieldHandlerInterface.

References Drupal\config(), and t().

Here is the call graph for this function:

getEntity ( ResultRow  $values)

{Gets the entity matching the current row and relationship.

Parameters
\Drupal\views\ResultRow$valuesAn object containing all retrieved values.
Returns
Returns the entity matching the values.
}

Implements FieldHandlerInterface.

Referenced by LinkBase\addLangcode(), LinkApprove\getUrlInfo(), EntityLink\getUrlInfo(), ContactLink\getUrlInfo(), Permissions\preRender(), EntityLink\render(), EntityOperations\render(), ContactLink\renderLink(), and BulkForm\viewsForm().

Here is the caller graph for this function:

getFieldTokenPlaceholder ( )
protected

Returns a token placeholder for the current field.

Returns
string A token placeholder.
getPreviousFieldLabels ( )
protected

Returns all field labels of fields before this field.

Returns
array An array of field labels keyed by their field IDs.

Referenced by Links\buildOptionsForm().

Here is the caller graph for this function:

getRenderer ( )
protected

Returns the render API renderer.

Returns

References Drupal\service().

Here is the call graph for this function:

getTokenValuesRecursive ( array  $array,
array  $parent_keys = array() 
)
protected

Recursive function to add replacements for nested query string parameters.

E.g. if you pass in the following array: array( 'foo' => array( 'a' => 'value', 'b' => 'value', ), 'bar' => array( 'a' => 'value', 'b' => array( 'c' => value, ), ), );

Would yield the following array of tokens: array( 'foo_a' => 'value' 'foo_b' => 'value' 'bar_a' => 'value' 'bar_b_c' => 'value' );

Parameters
$arrayAn array of values.
$parent_keysAn array of parent keys. This will represent the array depth.
Returns
An array of available tokens, with nested keys representative of the array structure.
getValue ( ResultRow  $values,
  $field = NULL 
)

{Gets the value that's supposed to be rendered.This api exists so that other modules can easy set the values of the field without having the need to change the render method as well.

Parameters
\Drupal\views\ResultRow$valuesAn object containing all retrieved values.
string$fieldOptional name of the field where the value is stored.
}

Implements FieldHandlerInterface.

Referenced by PrerenderList\getItems(), Roles\preRender(), Permissions\preRender(), EntityLabel\preRender(), DblogOperations\render(), LastTimestamp\render(), Markup\render(), LanguageField\render(), Url\render(), FileSize\render(), DblogMessage\render(), StatisticsLastCommentName\render(), Path\render(), HistoryUserTimestamp\render(), File\render(), Node\render(), UserData\render(), Boolean\render(), Date\render(), NumericField\render(), File\renderLink(), and Node\renderLink().

Here is the caller graph for this function:

init ( ViewExecutable  $view,
DisplayPluginBase  $display,
array &  $options = NULL 
)

{Initialize the plugin.

Parameters
\Drupal\views\ViewExecutable$viewThe view object.
\Drupal\views\Plugin\views\display\DisplayPluginBase$displayThe display handler.
array$optionsThe options configured for this plugin.
}

Implements ViewsPluginInterface.

isValueEmpty (   $value,
  $empty_zero,
  $no_skip_empty = TRUE 
)

{Checks if a field value is empty.

Parameters
$valueThe field value.
bool$empty_zeroWhether or not this field is configured to consider 0 as empty.
bool$no_skip_emptyWhether or not to use empty() to check the value.
Returns
bool TRUE if the value is considered empty, FALSE otherwise.
}

Implements FieldHandlerInterface.

label ( )

{Gets this field's label.}

Implements FieldHandlerInterface.

linkGenerator ( )
protected

Gets the link generator.

Returns

References Drupal\linkGenerator().

Here is the call graph for this function:

postRender ( ResultRow  $row,
  $output 
)

{Runs after every field has been rendered.This is meant to be used mainly to deal with field handlers whose output cannot be cached at row level but can be cached at display level. The typical example is the row counter. For completely uncacheable field output placeholders should be used.

Parameters
\Drupal\views\ResultRow$rowAn array of all ResultRow objects returned from the query.
$outputThe field rendered output.
Returns
string[] An associative array of post-render token values keyed by placeholder.
See Also
}

Implements FieldHandlerInterface.

Referenced by CounterTest\renderCounter().

Here is the caller graph for this function:

preRender ( $values)

{Runs before any fields are rendered.This gives the handlers some time to set up before any handler has been rendered.

Parameters
\Drupal\views\ResultRow[]$values An array of all ResultRow objects returned from the query.
}

Implements FieldHandlerInterface.

query ( )

Called to add the field to a query.

Implements ViewsPluginInterface.

References FieldPluginBase\addAdditionalFields(), and HandlerBase\ensureMyTable().

Referenced by FieldPluginBase\addAdditionalFields(), FieldPluginBase\clickSort(), Field\clickSort(), and Field\query().

Here is the call graph for this function:

Here is the caller graph for this function:

render ( ResultRow  $values)

{Renders the field.

Parameters
\Drupal\views\ResultRow$valuesThe values retrieved from a single row of a view's query result.
Returns
string| The rendered output. If the output is safe it will be wrapped in an object that implements MarkupInterface. If it is empty or unsafe it will be a string.
}

Implements FieldHandlerInterface.

Referenced by CounterTest\renderCounter().

Here is the caller graph for this function:

renderAltered (   $alter,
  $tokens 
)
protected

Render this field as user-defined altered text.

Referenced by FieldPluginBase\tokenizeValue().

Here is the caller graph for this function:

renderAsLink (   $alter,
  $text,
  $tokens 
)
protected

Render this field as a link, with the info from a fieldset set by the user.

renderText (   $alter)

{Performs an advanced text render for the item.This is separated out as some fields may render lists, and this allows each item to be handled individually.

Parameters
array$alterThe alter array of options to use.
  • max_length: Maximum length of the string, the rest gets truncated.
  • word_boundary: Trim only on a word boundary.
  • ellipsis: Show an ellipsis (…) at the end of the trimmed string.
  • html: Make sure that the html is correct.
Returns
string| The rendered output. If the output is safe it will be wrapped in an object that implements MarkupInterface. If it is empty or unsafe it will be a string.
}

Implements FieldHandlerInterface.

References t().

Here is the call graph for this function:

renderTrimText (   $alter,
  $value 
)
protected

Trims the field down to the specified length.

Parameters
array$alterThe alter array of options to use.
  • max_length: Maximum length of the string, the rest gets truncated.
  • word_boundary: Trim only on a word boundary.
  • ellipsis: Show an ellipsis (…) at the end of the trimmed string.
  • html: Make sure that the html is correct.
string$valueThe string which should be trimmed.
Returns
string The rendered trimmed string.
submitOptionsForm ( $form,
FormStateInterface  $form_state 
)

Performs some cleanup tasks on the options array before saving it.

Implements ViewsPluginInterface.

References FormStateInterface\getValue().

Here is the call graph for this function:

theme ( ResultRow  $values)

{Passes values to drupal_render() using $this->themeFunctions() as theme.

Parameters
\Drupal\views\ResultRow$valuesHolds single row of a view's result set.
Returns
string| Returns rendered output of the given theme implementation. If the output is safe it will be wrapped in an object that implements MarkupInterface. If it is empty or unsafe it will be a string.
}

Implements FieldHandlerInterface.

themeFunctions ( )

Provide a full list of possible theme templates used by this style.

Implements ViewsPluginInterface.

tokenizeValue (   $value,
  $row_index = NULL 
)

{Replaces a value with tokens from the last field.This function actually figures out which field was last and uses its tokens so they will all be available.

Parameters
string$valueThe raw string.
bool$row_indexThe index of current row.
}

Implements FieldHandlerInterface.

References FieldPluginBase\renderAltered().

Referenced by FieldPluginBase\elementClasses(), FieldPluginBase\elementLabelClasses(), and FieldPluginBase\elementWrapperClasses().

Here is the call graph for this function:

Here is the caller graph for this function:

static trimText (   $alter,
  $value 
)
static

Trims the field down to the specified length.

Parameters
array$alterThe alter array of options to use.
  • max_length: Maximum length of the string, the rest gets truncated.
  • word_boundary: Trim only on a word boundary.
  • ellipsis: Show an ellipsis (…) at the end of the trimmed string.
  • html: Make sure that the html is correct.
string$valueThe string which should be trimmed.
Returns
string The trimmed string.

References t().

Here is the call graph for this function:

useStringGroupBy ( )

{Determines if this field will be available as an option to group the result by in the style settings.

Returns
bool TRUE if this field handler is groupable, otherwise FALSE.
}

Implements FieldHandlerInterface.

Field Documentation

const RENDER_TEXT_PHASE_COMPLETELY = 1

Indicator of the renderText() method for rendering the whole element. (if no render_item() method is available).

const RENDER_TEXT_PHASE_EMPTY = 2

Indicator of the renderText() method for rendering the empty text.

const RENDER_TEXT_PHASE_SINGLE_ITEM = 0

Indicator of the renderText() method for rendering a single item. (If no render_item() is present).


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