abstract class FormWidgetBase in Typed Data API enhancements 8
Base class for 'form widget' plugin implementations.
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
- class \Drupal\typed_data\Widget\FormWidgetBase implements ContainerFactoryPluginInterface, FormWidgetInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
Expanded class hierarchy of FormWidgetBase
6 files declare their use of FormWidgetBase
- BrokenWidget.php in src/
Plugin/ TypedDataFormWidget/ BrokenWidget.php - DatetimeRangeWidget.php in src/
Plugin/ TypedDataFormWidget/ DatetimeRangeWidget.php - DatetimeWidget.php in src/
Plugin/ TypedDataFormWidget/ DatetimeWidget.php - SelectWidget.php in src/
Plugin/ TypedDataFormWidget/ SelectWidget.php - TextareaWidget.php in src/
Plugin/ TypedDataFormWidget/ TextareaWidget.php
File
- src/
Widget/ FormWidgetBase.php, line 15
Namespace
Drupal\typed_data\WidgetView source
abstract class FormWidgetBase extends PluginBase implements FormWidgetInterface, ContainerFactoryPluginInterface {
/**
* The typed data plugin manager.
*
* @var \Drupal\Core\TypedData\TypedDataManagerInterface
*/
protected $typedDataManager;
/**
* Constructs a FormWidgetBase object.
*
* @param array $configuration
* A configuration array containing information about the plugin instance.
* @param string $plugin_id
* The plugin ID for the plugin instance.
* @param mixed $plugin_definition
* The plugin implementation definition.
* @param \Drupal\Core\TypedData\TypedDataManagerInterface $typed_data_manager
* The typed data plugin manager.
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition, TypedDataManagerInterface $typed_data_manager) {
parent::__construct($configuration + $this
->defaultConfiguration(), $plugin_id, $plugin_definition);
$this->typedDataManager = $typed_data_manager;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static($configuration, $plugin_id, $plugin_definition, $container
->get('typed_data_manager'));
}
/**
* {@inheritdoc}
*/
public function defaultConfiguration() {
return [];
}
/**
* {@inheritdoc}
*/
public function getConfiguration() {
return $this->configuration;
}
/**
* {@inheritdoc}
*/
public function setConfiguration(array $configuration) {
$this->configuration = NestedArray::mergeDeep($this
->defaultConfiguration(), $configuration);
}
/**
* Create a default DrupalDateTime object.
*
* This is used in the DateTimeWidget and DateTimeRangeWidget forms.
*
* @param string $date
* (optional) A formatted date string as stored by the widgets. If no value
* is given an empty date with time 12:00 noon is created.
*
* @return object
* A DrupalDateTime object with the required date and time values.
*/
public function createDefaultDateTime($date) {
if (!empty($date)) {
$default = new DrupalDateTime($date);
}
else {
// The DrupalDateTime object is created first with no parameters so that
// it has the current users timezone. Then setDate with year 0 has the
// effect that the widget date remains empty but allows a default time to
// be set using setTime(). This is done in setDefaultDateTime().
$default = new DrupalDateTime();
$default
->setDate(0, 1, 1);
$default
->setDefaultDateTime();
}
return $default;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DependencySerializationTrait:: |
protected | property | An array of entity type IDs keyed by the property name of their storages. | |
DependencySerializationTrait:: |
protected | property | An array of service IDs keyed by property name used for serialization. | |
DependencySerializationTrait:: |
public | function | 1 | |
DependencySerializationTrait:: |
public | function | 2 | |
FormWidgetBase:: |
protected | property | The typed data plugin manager. | |
FormWidgetBase:: |
public static | function |
Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface:: |
|
FormWidgetBase:: |
public | function | Create a default DrupalDateTime object. | |
FormWidgetBase:: |
public | function |
Gets default configuration for this plugin. Overrides ConfigurableInterface:: |
6 |
FormWidgetBase:: |
public | function |
Gets this plugin's configuration. Overrides ConfigurableInterface:: |
|
FormWidgetBase:: |
public | function |
Sets the configuration for this plugin instance. Overrides ConfigurableInterface:: |
|
FormWidgetBase:: |
public | function |
Constructs a FormWidgetBase object. Overrides PluginBase:: |
|
FormWidgetInterface:: |
public | function | Extracts the data value from submitted form values. | 6 |
FormWidgetInterface:: |
public | function | Reports validation errors against actual form elements. | 6 |
FormWidgetInterface:: |
public | function | Creates the widget's form elements for editing the given data. | 6 |
FormWidgetInterface:: |
public | function | Defines the supported configuration settings. | 6 |
FormWidgetInterface:: |
public | function | Returns if the widget can be used for the provided data. | 6 |
MessengerTrait:: |
protected | property | The messenger. | 29 |
MessengerTrait:: |
public | function | Gets the messenger. | 29 |
MessengerTrait:: |
public | function | Sets the messenger. | |
PluginBase:: |
protected | property | Configuration information passed into the plugin. | 1 |
PluginBase:: |
protected | property | The plugin implementation definition. | 1 |
PluginBase:: |
protected | property | The plugin_id. | |
PluginBase:: |
constant | A string which is used to separate base plugin IDs from the derivative ID. | ||
PluginBase:: |
public | function |
Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the definition of the plugin implementation. Overrides PluginInspectionInterface:: |
3 |
PluginBase:: |
public | function |
Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: |
|
PluginBase:: |
public | function | Determines if the plugin is configurable. | |
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. |