abstract class ExtraFieldPlusDisplayBase in Extra Field Settings Provider 8
Same name and namespace in other branches
- 8.2 src/Plugin/ExtraFieldPlusDisplayBase.php \Drupal\extra_field_plus\Plugin\ExtraFieldPlusDisplayBase
Base class for Extra field Plus Display plugins.
Hierarchy
- class \Drupal\extra_field_plus\Plugin\ExtraFieldPlusDisplayBase extends \Drupal\extra_field\Plugin\ExtraFieldDisplayBase implements ExtraFieldPlusDisplayInterface uses StringTranslationTrait
Expanded class hierarchy of ExtraFieldPlusDisplayBase
1 file declares its use of ExtraFieldPlusDisplayBase
- ExampleNodeLabel.php in modules/
extra_field_plus_example/ src/ Plugin/ ExtraField/ Display/ ExampleNodeLabel.php
File
- src/
Plugin/ ExtraFieldPlusDisplayBase.php, line 11
Namespace
Drupal\extra_field_plus\PluginView source
abstract class ExtraFieldPlusDisplayBase extends ExtraFieldDisplayBase implements ExtraFieldPlusDisplayInterface {
use StringTranslationTrait;
/**
* {@inheritdoc}
*/
public function getSettings() {
$field_id = 'extra_field_' . $this
->getPluginId();
$display = $this
->getEntityViewDisplay();
$component = $display
->getComponent($field_id);
$default_settings = (array) $this
->getDefaultFormValues();
if (!empty($component['settings'])) {
$settings = array_merge($default_settings, array_intersect_key($component['settings'], $default_settings));
}
else {
$settings = $default_settings;
}
return $settings;
}
/**
* {@inheritdoc}
*/
public function getSetting($name) {
$settings = $this
->getSettings();
return isset($settings[$name]) ? $settings[$name] : NULL;
}
/**
* Provides field settings form.
*
* @return array
* The field settings form.
*/
protected function settingsForm() {
$elements = [];
return $elements;
}
/**
* {@inheritdoc}
*/
public function getSettingsForm() {
$default_values = (array) $this
->getDefaultFormValues();
$elements = (array) $this
->settingsForm();
if (!empty($elements)) {
foreach ($elements as $name => &$element) {
$element['#default_value'] = isset($default_values[$name]) ? $default_values[$name] : '';
}
}
return $elements;
}
/**
* Provides field settings form default values.
*
* @return array
* The form values.
*/
protected function defaultFormValues() {
return [];
}
/**
* {@inheritdoc}
*/
public function getDefaultFormValues() {
return $this
->defaultFormValues();
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ExtraFieldPlusDisplayBase:: |
protected | function | Provides field settings form default values. | 2 |
ExtraFieldPlusDisplayBase:: |
public | function |
Returns field settings form default values. Overrides ExtraFieldPlusDisplayInterface:: |
|
ExtraFieldPlusDisplayBase:: |
public | function |
Returns field setting. Overrides ExtraFieldPlusDisplayInterface:: |
|
ExtraFieldPlusDisplayBase:: |
public | function |
Returns field settings. Overrides ExtraFieldPlusDisplayInterface:: |
|
ExtraFieldPlusDisplayBase:: |
public | function |
Returns field settings form. Overrides ExtraFieldPlusDisplayInterface:: |
|
ExtraFieldPlusDisplayBase:: |
protected | function | Provides field settings form. | 2 |
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. |