class DateFormat in Zircon Profile 8
Same name in this branch
- 8 core/modules/config_translation/src/FormElement/DateFormat.php \Drupal\config_translation\FormElement\DateFormat
- 8 core/lib/Drupal/Core/Datetime/Entity/DateFormat.php \Drupal\Core\Datetime\Entity\DateFormat
Same name and namespace in other branches
- 8.0 core/modules/config_translation/src/FormElement/DateFormat.php \Drupal\config_translation\FormElement\DateFormat
Defines the date format element for the configuration translation interface.
Hierarchy
- class \Drupal\config_translation\FormElement\FormElementBase implements ElementInterface uses StringTranslationTrait
- class \Drupal\config_translation\FormElement\DateFormat
Expanded class hierarchy of DateFormat
File
- core/
modules/ config_translation/ src/ FormElement/ DateFormat.php, line 15 - Contains \Drupal\config_translation\FormElement\DateFormat.
Namespace
Drupal\config_translation\FormElementView source
class DateFormat extends FormElementBase {
/**
* {@inheritdoc}
*/
public function getTranslationElement(LanguageInterface $translation_language, $source_config, $translation_config) {
/** @var \Drupal\Core\Datetime\DateFormatterInterface $date_formatter */
$date_formatter = \Drupal::service('date.formatter');
$description = $this
->t('A user-defined date format. See the <a href=":url">PHP manual</a> for available options.', array(
':url' => 'http://php.net/manual/function.date.php',
));
$format = $this
->t('Displayed as %date_format', array(
'%date_format' => $date_formatter
->format(REQUEST_TIME, 'custom', $translation_config),
));
return [
'#type' => 'textfield',
'#description' => $description,
'#field_suffix' => ' <small data-drupal-date-formatter="preview">' . $format . '</small>',
'#attributes' => [
'data-drupal-date-formatter' => 'source',
],
'#attached' => [
'drupalSettings' => [
'dateFormats' => $date_formatter
->getSampleDateFormats($translation_language
->getId()),
],
'library' => [
'system/drupal.system.date',
],
],
] + parent::getTranslationElement($translation_language, $source_config, $translation_config);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DateFormat:: |
public | function |
Returns the translation form element for a given configuration definition. Overrides FormElementBase:: |
|
FormElementBase:: |
protected | property | The data definition of the element this form element is for. | |
FormElementBase:: |
protected | property | The schema element this form is for. | |
FormElementBase:: |
public static | function |
Creates a form element instance from a schema definition. Overrides ElementInterface:: |
|
FormElementBase:: |
protected | function | Returns the source element for a given configuration definition. | 2 |
FormElementBase:: |
public | function |
Builds a render array containg the source and translation form elements. Overrides ElementInterface:: |
|
FormElementBase:: |
public | function |
Sets configuration based on a nested form value array. Overrides ElementInterface:: |
1 |
FormElementBase:: |
public | function | Constructs a FormElementBase. | |
StringTranslationTrait:: |
protected | property | The string translation service. | |
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. |