private function ReadonlyFieldWidget::getFormatterInstance in Read-only Field Widget 8
Retrieves a formatter plugin instance.
Parameters
string $plugin_id: The plugin_id for the formatter.
Return value
\Drupal\Core\Field\FormatterInterface A formatter plugin instance.
2 calls to ReadonlyFieldWidget::getFormatterInstance()
- ReadonlyFieldWidget::settingsForm in src/
Plugin/ Field/ FieldWidget/ ReadonlyFieldWidget.php - Returns a form to configure settings for the widget.
- ReadonlyFieldWidget::settingsSummary in src/
Plugin/ Field/ FieldWidget/ ReadonlyFieldWidget.php - Returns a short summary for the current widget settings.
File
- src/
Plugin/ Field/ FieldWidget/ ReadonlyFieldWidget.php, line 222
Class
- ReadonlyFieldWidget
- Plugin implementation of the 'readonly_field_widget' widget.
Namespace
Drupal\readonly_field_widget\Plugin\Field\FieldWidgetCode
private function getFormatterInstance($plugin_id = NULL) {
$settings = $this
->getSetting('formatter_settings');
if (empty($plugin_id)) {
$plugin_id = $this
->getSetting('formatter_type');
}
$options = [
'view_mode' => 'default',
'field_definition' => $this->fieldDefinition,
'configuration' => [
'type' => $plugin_id,
'settings' => isset($settings[$plugin_id]) ? $settings[$plugin_id] : [],
],
];
return $this->fieldFormatterManager
->getInstance($options);
}