class FieldThirdPartyTestHooks
Hook implementations for field_third_party_test.
Hierarchy
- class \Drupal\field_third_party_test\Hook\FieldThirdPartyTestHooks uses \Drupal\Core\StringTranslation\StringTranslationTrait
Expanded class hierarchy of FieldThirdPartyTestHooks
File
-
core/
modules/ field/ tests/ modules/ field_third_party_test/ src/ Hook/ FieldThirdPartyTestHooks.php, line 20
Namespace
Drupal\field_third_party_test\HookView source
class FieldThirdPartyTestHooks {
use StringTranslationTrait;
public function __construct(protected ElementInfoManagerInterface $elementInfoManager) {
}
/**
* Implements hook_field_widget_third_party_settings_form().
*/
public function fieldWidgetThirdPartySettingsForm(WidgetInterface $plugin, FieldDefinitionInterface $field_definition, $form_mode, $form, FormStateInterface $form_state) : array {
$textfield = $this->elementInfoManager
->fromClass(Textfield::class);
$textfield->title = $this->t('3rd party widget settings form');
$textfield->default_value = $plugin->getThirdPartySetting('field_third_party_test', 'field_test_widget_third_party_settings_form');
return $textfield->toRenderable('field_test_widget_third_party_settings_form');
}
/**
* Implements hook_field_widget_third_party_settings_form().
*/
public function fieldWidgetThirdPartySettingsFormAdditionalImplementation(WidgetInterface $plugin, FieldDefinitionInterface $field_definition, $form_mode, $form, FormStateInterface $form_state) : array {
$number = $this->elementInfoManager
->fromClass(Number::class);
$number->title = $this->t('Second 3rd party widget settings form');
$number->default_value = $plugin->getThirdPartySetting('field_third_party_test', 'second_field_widget_third_party_settings_form');
return $number->toRenderable('second_field_widget_third_party_settings_form');
}
/**
* Implements hook_field_widget_settings_summary_alter().
*/
public function fieldWidgetSettingsSummaryAlter(&$summary, $context) : void {
$summary[] = 'field_test_field_widget_settings_summary_alter';
}
/**
* Implements hook_field_formatter_third_party_settings_form().
*/
public function fieldFormatterThirdPartySettingsForm(FormatterInterface $plugin, FieldDefinitionInterface $field_definition, $view_mode, $form, FormStateInterface $form_state) : array {
$textfield = $this->elementInfoManager
->fromClass(Textfield::class);
$textfield->title = $this->t('3rd party formatter settings form');
$textfield->default_value = $plugin->getThirdPartySetting('field_third_party_test', 'field_test_field_formatter_third_party_settings_form');
return $textfield->toRenderable('field_test_field_formatter_third_party_settings_form');
}
/**
* Implements hook_field_formatter_third_party_settings_form().
*/
public function fieldFormatterThirdPartySettingsFormAdditionalImplementation(FormatterInterface $plugin, FieldDefinitionInterface $field_definition, $view_mode, $form, FormStateInterface $form_state) : array {
$number = $this->elementInfoManager
->fromClass(Number::class);
$number->title = $this->t('Second 3rd party formatter settings form');
$number->default_value = $plugin->getThirdPartySetting('field_third_party_test', 'second_field_formatter_third_party_settings_form');
return $number->toRenderable('second_field_formatter_third_party_settings_form');
}
/**
* Implements hook_field_formatter_settings_summary_alter().
*/
public function fieldFormatterSettingsSummaryAlter(&$summary, $context) : void {
$summary[] = 'field_test_field_formatter_settings_summary_alter';
}
}
Members
Title Sort descending | Modifiers | Object type | Summary | Overrides |
---|---|---|---|---|
FieldThirdPartyTestHooks::fieldFormatterSettingsSummaryAlter | public | function | Implements hook_field_formatter_settings_summary_alter(). | |
FieldThirdPartyTestHooks::fieldFormatterThirdPartySettingsForm | public | function | Implements hook_field_formatter_third_party_settings_form(). | |
FieldThirdPartyTestHooks::fieldFormatterThirdPartySettingsFormAdditionalImplementation | public | function | Implements hook_field_formatter_third_party_settings_form(). | |
FieldThirdPartyTestHooks::fieldWidgetSettingsSummaryAlter | public | function | Implements hook_field_widget_settings_summary_alter(). | |
FieldThirdPartyTestHooks::fieldWidgetThirdPartySettingsForm | public | function | Implements hook_field_widget_third_party_settings_form(). | |
FieldThirdPartyTestHooks::fieldWidgetThirdPartySettingsFormAdditionalImplementation | public | function | Implements hook_field_widget_third_party_settings_form(). | |
FieldThirdPartyTestHooks::__construct | public | function | ||
StringTranslationTrait::$stringTranslation | protected | property | The string translation service. | 3 |
StringTranslationTrait::formatPlural | protected | function | Formats a string containing a count of items. | |
StringTranslationTrait::getNumberOfPlurals | protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait::getStringTranslation | protected | function | Gets the string translation service. | |
StringTranslationTrait::setStringTranslation | public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait::t | protected | function | Translates a string to the current language or to a given language. | 1 |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.