Drupal 8  8.0.2
LinkFormatter Class Reference
Inheritance diagram for LinkFormatter:

Public Member Functions

 __construct ($plugin_id, $plugin_definition, FieldDefinitionInterface $field_definition, array $settings, $label, $view_mode, array $third_party_settings, PathValidatorInterface $path_validator)
 
 settingsForm (array $form, FormStateInterface $form_state)
 
 settingsSummary ()
 
 viewElements (FieldItemListInterface $items, $langcode)
 
- Public Member Functions inherited from FormatterBase
 __construct ($plugin_id, $plugin_definition, FieldDefinitionInterface $field_definition, array $settings, $label, $view_mode, array $third_party_settings)
 
 view (FieldItemListInterface $items, $langcode=NULL)
 
 settingsForm (array $form, FormStateInterface $form_state)
 
 settingsSummary ()
 
 prepareView (array $entities_items)
 
- Public Member Functions inherited from PluginSettingsBase
 getSettings ()
 
 getSetting ($key)
 
 setSettings (array $settings)
 
 setSetting ($key, $value)
 
 getThirdPartySettings ($module=NULL)
 
 getThirdPartySetting ($module, $key, $default=NULL)
 
 setThirdPartySetting ($module, $key, $value)
 
 unsetThirdPartySetting ($module, $key)
 
 getThirdPartyProviders ()
 
 calculateDependencies ()
 
 onDependencyRemoval (array $dependencies)
 
- Public Member Functions inherited from PluginInspectionInterface
 getPluginId ()
 
 getPluginDefinition ()
 

Static Public Member Functions

static create (ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition)
 
static defaultSettings ()
 
- Static Public Member Functions inherited from FormatterBase
static isApplicable (FieldDefinitionInterface $field_definition)
 
- Static Public Member Functions inherited from PluginSettingsBase
static defaultSettings ()
 

Protected Member Functions

 buildUrl (LinkItemInterface $item)
 
- Protected Member Functions inherited from FormatterBase
 getFieldSettings ()
 
 getFieldSetting ($setting_name)
 
- Protected Member Functions inherited from PluginSettingsBase
 mergeDefaults ()
 

Protected Attributes

 $pathValidator
 
- Protected Attributes inherited from FormatterBase
 $fieldDefinition
 
 $settings
 
 $label
 
 $viewMode
 
- Protected Attributes inherited from PluginSettingsBase
 $settings = array()
 
 $thirdPartySettings = array()
 
 $defaultSettingsMerged = FALSE
 

Detailed Description

Plugin implementation of the 'link' formatter.

( id = "link", label = ("Link"), field_types = { "link" } )

Constructor & Destructor Documentation

__construct (   $plugin_id,
  $plugin_definition,
FieldDefinitionInterface  $field_definition,
array  $settings,
  $label,
  $view_mode,
array  $third_party_settings,
PathValidatorInterface  $path_validator 
)

Constructs a new LinkFormatter.

Parameters
string$plugin_idThe plugin_id for the formatter.
mixed$plugin_definitionThe plugin implementation definition.
\Drupal\Core\Field\FieldDefinitionInterface$field_definitionThe definition of the field to which the formatter is associated.
array$settingsThe formatter settings.
string$labelThe formatter label display setting.
string$view_modeThe view mode.
array$third_party_settingsThird party settings.
\Drupal\Core\Path\PathValidatorInterface$path_validatorThe path validator service.

References Drupal\pathValidator().

Here is the call graph for this function:

Member Function Documentation

buildUrl ( LinkItemInterface  $item)
protected

Builds the object for a link field item.

Parameters
\Drupal\link\LinkItemInterface$itemThe link field item being rendered.
Returns
An Url object.

References Url\fromRoute(), PluginSettingsBase\getSettings(), and LinkItemInterface\getUrl().

Referenced by LinkSeparateFormatter\viewElements(), and LinkFormatter\viewElements().

Here is the call graph for this function:

Here is the caller graph for this function:

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.

static defaultSettings ( )
static

{Defines the default settings for this plugin.

Returns
array A list of default settings, keyed by the setting name.
}

Implements PluginSettingsInterface.

settingsForm ( array  $form,
FormStateInterface  $form_state 
)

{Returns a form to configure settings for the formatter.Invoked from to allow administrators to configure the formatter. The field_ui module takes care of handling submitted form values.

Parameters
array$formThe form where the settings form is being included in.
\Drupal\Core\Form\FormStateInterface$form_stateThe current state of the form.
Returns
array The form elements for the formatter settings.
}

Implements FormatterInterface.

References PluginInspectionInterface\getPluginId(), PluginSettingsBase\getSetting(), and t().

Here is the call graph for this function:

settingsSummary ( )

{Returns a short summary for the current formatter settings.If an empty result is returned, a UI can still be provided to display a settings form in case the formatter has configurable settings.

Returns
string[] A short summary of the formatter settings.
}

Implements FormatterInterface.

References PluginInspectionInterface\getPluginId(), PluginSettingsBase\getSettings(), and t().

Here is the call graph for this function:

viewElements ( FieldItemListInterface  $items,
  $langcode 
)

{Builds a renderable array for a field value.

Parameters
\Drupal\Core\Field\FieldItemListInterface$itemsThe field values to be rendered.
string$langcodeThe language that should be used to render the field.
Returns
array A renderable array for $items, as an array of child elements keyed by consecutive numeric indexes starting from 0.
}

Implements FormatterInterface.

References LinkFormatter\buildUrl(), FieldItemListInterface\getEntity(), PluginSettingsBase\getSettings(), Drupal\token(), and Unicode\truncate().

Here is the call graph for this function:


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