Drupal 8  8.0.2
PluginBase Class Reference
Inheritance diagram for PluginBase:

Public Member Functions

 __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 ()
 

Static Public Member Functions

static create (ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition)
 
static preRenderAddFieldsetMarkup (array $form)
 
static preRenderFlattenData ($form)
 
static queryLanguageSubstitutions ()
 

Data Fields

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

 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

 $usesOptions = FALSE
 
 $renderer
 

Detailed Description

Base class for any views plugin types.

Via the definition the plugin may specify a theme function or template to be used for the plugin. It also can auto-register the theme implementation for that file or function.

  • theme: the theme implementation to use in the plugin. This may be the name of the function (without theme_ prefix) or the template file (without template engine extension). If a template file should be used, the file has to be placed in the module's templates folder. Example: theme = "mymodule_row" of module "mymodule" will implement mymodule-row.html.twig in the [..]/modules/mymodule/templates folder.
  • register_theme: (optional) When set to TRUE (default) the theme is registered automatically. When set to FALSE the plugin reuses an existing theme implementation, defined by another module or views plugin.
  • theme_file: (optional) the location of an include file that may hold the theme or preprocess function. The location has to be relative to module's root directory.
  • module: machine name of the module. It must be present for any plugin that wants to register a theme.

Constructor & Destructor Documentation

__construct ( array  $configuration,
  $plugin_id,
  $plugin_definition 
)

Constructs a PluginBase object.

Parameters
array$configurationA configuration array containing information about the plugin instance.
string$plugin_idThe plugin_id for the plugin instance.
mixed$plugin_definitionThe plugin implementation definition.

Member Function Documentation

buildOptionsForm ( $form,
FormStateInterface  $form_state 
)

{Provide a form to edit options for this plugin.}

Implements ViewsPluginInterface.

calculateDependencies ( )

{Calculates dependencies for the configured plugin.Dependencies are saved in the plugin's configuration entity and are used to determine configuration synchronization order. For example, if the plugin integrates with specific user roles, this method should return an array of dependencies listing the specified roles.

Returns
array An array of dependencies grouped by type (config, content, module, theme). For example:
array(
'config' => array('user.role.anonymous', 'user.role.authenticated'),
'content' => array('node:article:f0a189e6-55fb-47fb-8005-5bef81c44d6d'),
'module' => array('node', 'user'),
'theme' => array('seven'),
);
See Also
::getConfigDependencyName()
}

Implements DependentPluginInterface.

static create ( ContainerInterface  $container,
array  $configuration,
  $plugin_id,
  $plugin_definition 
)
static

{Creates an instance of the plugin.

Parameters
\Symfony\Component\DependencyInjection\ContainerInterface$containerThe container to pull out services used in the plugin.
array$configurationA configuration array containing information about the plugin instance.
string$plugin_idThe plugin ID for the plugin instance.
mixed$plugin_definitionThe plugin implementation definition.
Returns
static Returns an instance of this plugin.
}

Implements ContainerFactoryPluginInterface.

defineOptions ( )
protected

Information about options for all kinds of purposes will be held here.

'option_name' => array(
- 'default' => default value,
- 'contains' => (optional) array of items this contains, with its own
defaults, etc. If contains is set, the default will be ignored and
assumed to be array().
),
Returns
array Returns the options of this handler/plugin.

Referenced by PluginBase\filterByDefinedOptions(), PluginBase\init(), and PluginBase\unpackOptions().

Here is the caller graph for this function:

destroy ( )

{Clears a plugin.}

Implements ViewsPluginInterface.

References PluginBase\query().

Here is the call graph for this function:

doFilterByDefinedOptions ( array &  $storage,
array  $options 
)
protected

Do the work to filter out stored options depending on the defined options.

Parameters
array$storageThe stored options.
array$optionsThe defined options.

References PluginBase\doFilterByDefinedOptions().

Referenced by PluginBase\doFilterByDefinedOptions(), and PluginBase\filterByDefinedOptions().

Here is the call graph for this function:

Here is the caller graph for this function:

filterByDefinedOptions ( array &  $storage)

{Filter out stored options depending on the defined options.

Parameters
array$storageThe stored options.
}

Implements ViewsPluginInterface.

References PluginBase\defineOptions(), and PluginBase\doFilterByDefinedOptions().

Here is the call graph for this function:

getAvailableGlobalTokens (   $prepared = FALSE,
array  $types = array() 
)

{Returns an array of available token replacements.

Parameters
bool$preparedWhether to return the raw token info for each token or an array of prepared tokens for each type. E.g. "[view:name]".
array$typesAn array of additional token types to return, defaults to 'site' and 'view'.
Returns
array An array of available token replacement info or tokens, grouped by type.
}

Implements ViewsPluginInterface.

References Drupal\token().

Referenced by PluginBase\globalTokenForm().

Here is the call graph for this function:

Here is the caller graph for this function:

getProvider ( )

{Returns the plugin provider.

Returns
string
}

Implements ViewsPluginInterface.

References PluginInspectionInterface\getPluginDefinition().

Here is the call graph for this function:

getRenderer ( )
protected

Returns the render API renderer.

Returns

References Drupal\service().

Referenced by PluginBase\viewsTokenReplace().

Here is the call graph for this function:

Here is the caller graph for this function:

globalTokenForm ( $form,
FormStateInterface  $form_state 
)

{Adds elements for available core tokens to a form.

Parameters
array$formThe form array to alter, passed by reference.
\Drupal\Core\Form\FormStateInterface$form_stateThe current state of the form.
}

Implements ViewsPluginInterface.

References PluginBase\getAvailableGlobalTokens(), and t().

Referenced by Title\buildOptionsForm(), TestExample\buildOptionsForm(), and TokenizeAreaPluginBase\tokenForm().

Here is the call graph for this function:

Here is the caller graph for this function:

globalTokenReplace (   $string = '',
array  $options = array() 
)

{Returns a string with any core tokens replaced.

Parameters
string$stringThe string to preform the token replacement on.
array$optionsAn array of options, as passed to ::replace().
Returns
string The tokenized string.
}

Implements ViewsPluginInterface.

Referenced by Title\preRender(), TestExample\render(), and TokenizeAreaPluginBase\tokenizeValue().

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.

References PluginBase\defineOptions(), PluginBase\setOptionDefaults(), and PluginBase\unpackOptions().

Here is the call graph for this function:

listLanguages (   $flags = LanguageInterface::STATE_ALL,
array  $current_values = NULL 
)
protected

Makes an array of languages, optionally including special languages.

Parameters
int$flags(optional) Flags for which languages to return (additive). Options:
  • ::STATE_ALL (default): All languages (configurable and default).
  • ::STATE_CONFIGURABLE: Configurable languages.
  • ::STATE_LOCKED: Locked languages.
  • ::STATE_SITE_DEFAULT: Add site default language; note that this is not included in STATE_ALL.
  • ::INCLUDE_NEGOTIATED: Add negotiated language types.
  • ::INCLUDE_ENTITY: Add entity row language types. Note that these are only supported for display options, not substituted in queries.
array | null$current_valuesThe currently-selected options in the list, if available.
Returns
array An array of language names, keyed by the language code. Negotiated and special languages have special codes that are substituted in queries by PluginBase::queryLanguageSubstitutions(). Only configurable languages and languages that are in $current_values are included in the list.

References LanguageInterface\LANGCODE_SITE_DEFAULT, Drupal\languageManager(), LanguageInterface\STATE_SITE_DEFAULT, and t().

Referenced by DisplayPluginBase\buildRenderingLanguageOptions(), and LanguageFilter\getValueOptions().

Here is the call graph for this function:

Here is the caller graph for this function:

pluginTitle ( )

{Return the human readable name of the display.This appears on the ui beside each plugin and beside the settings link.}

Implements ViewsPluginInterface.

static preRenderAddFieldsetMarkup ( array  $form)
static

{Moves form elements into fieldsets for presentation purposes.Many views forms use #tree = TRUE to keep their values in a hierarchy for easier storage. Moving the form elements into fieldsets during form building would break up that hierarchy. Therefore, we wait until the pre_render stage, where any changes we make affect presentation only and aren't reflected in $form_state->getValues().

Parameters
array$formThe form build array to alter.
Returns
array The form build array.
}

Implements ViewsPluginInterface.

References Element\children().

Here is the call graph for this function:

static preRenderFlattenData (   $form)
static

{Flattens the structure of form elements.If a form element has #flatten = TRUE, then all of it's children get moved to the same level as the element itself. So $form['to_be_flattened'][$key] becomes $form[$key], and $form['to_be_flattened'] gets unset.

Parameters
array$formThe form build array to alter.
Returns
array The form build array.
}

Implements ViewsPluginInterface.

References Element\children().

Here is the call graph for this function:

query ( )

{Add anything to the query that we might need to.}

Implements ViewsPluginInterface.

Referenced by Sql\build(), and PluginBase\destroy().

Here is the caller graph for this function:

static queryLanguageSubstitutions ( )
static

Returns substitutions for Views queries for languages.

This is needed so that the language options returned by PluginBase::listLanguages() are able to be used in queries. It is called by the Views module implementation of hook_views_query_substitutions() to get the language-related substitutions.

Returns
array An array in the format of hook_views_query_substitutions() that gives the query substitutions needed for the special language types.

References Drupal\languageManager().

Here is the call graph for this function:

setOptionDefaults ( array &  $storage,
array  $options 
)
protected

Fills up the options of the plugin with defaults.

Parameters
array$storageAn array which stores the actual option values of the plugin.
array$optionsAn array which describes the options of a plugin. Each element is an associative array containing:
  • default: The default value of one option. Should be translated to the interface text language selected for page if translatable.
  • (optional) contains: An array which describes the available options under the key. If contains is set, the default will be ignored and assumed to be an empty array.
  • (optional) 'bool': TRUE if the value is boolean, else FALSE.

References PluginBase\setOptionDefaults().

Referenced by PluginBase\init(), PluginBase\setOptionDefaults(), and TestHelperPlugin\testSetOptionDefaults().

Here is the call graph for this function:

Here is the caller graph for this function:

submitOptionsForm ( $form,
FormStateInterface  $form_state 
)

{Handle any special handling on the validate form.}

Implements ViewsPluginInterface.

Referenced by HandlerBase\submitTemporaryForm().

Here is the caller graph for this function:

summaryTitle ( )

{Returns the summary of the settings in the display.}

Implements ViewsPluginInterface.

References t().

Here is the call graph for this function:

themeFunctions ( )

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

Implements ViewsPluginInterface.

Referenced by SearchRow\render(), Opml\render(), Full\render(), Mini\render(), Mapping\render(), RowPluginBase\render(), OpmlFields\render(), DisplayPluginBase\render(), and StylePluginBase\renderRowGroup().

Here is the caller graph for this function:

unpackOptions ( $storage,
  $options,
  $definition = NULL,
  $all = TRUE,
  $check = TRUE 
)

{Unpack options over our existing defaults, drilling down into arrays so that defaults don't get totally blown away.}

Implements ViewsPluginInterface.

References PluginBase\defineOptions(), and PluginBase\unpackOptions().

Referenced by HandlerBase\init(), PluginBase\init(), and PluginBase\unpackOptions().

Here is the call graph for this function:

Here is the caller graph for this function:

usesOptions ( )

{Returns the usesOptions property.}

Implements ViewsPluginInterface.

validate ( )

{Validate that the plugin is correct and can be saved.

Returns
An array of error strings to tell the user what is wrong with this plugin.
}

Implements ViewsPluginInterface.

validateOptionsForm ( $form,
FormStateInterface  $form_state 
)

{Validate the options form.}

Implements ViewsPluginInterface.

viewsTokenReplace (   $text,
  $tokens 
)
protected

Replaces Views' tokens in a given string. The resulting string will be sanitized with Xss::filterAdmin.

Parameters
$textUnsanitized string with possible tokens.
$tokensArray of token => replacement_value items.
Returns
String

References Xss\filterAdmin(), and PluginBase\getRenderer().

Referenced by Links\getLinks(), DisplayPluginBase\renderMoreLink(), and StylePluginBase\tokenizeValue().

Here is the call graph for this function:

Here is the caller graph for this function:

Field Documentation

const INCLUDE_ENTITY = 32

Include entity row languages when listing languages.

See Also
::listLanguages()

Referenced by DisplayPluginBase\buildRenderingLanguageOptions().

const INCLUDE_NEGOTIATED = 16

Include negotiated languages when listing languages.

See Also
::listLanguages()

Referenced by DisplayPluginBase\buildRenderingLanguageOptions().

const VIEWS_QUERY_LANGUAGE_SITE_DEFAULT = '***LANGUAGE_site_default***'

Query string to indicate the site default language.

See Also
::LANGCODE_DEFAULT

Referenced by NodeLanguageTest\testLanguages().


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