You are here

protected function DateTimeExport::getDateFormat in Entity Export CSV 8

Loads the given format pattern for the given langcode.

Parameters

string $format: The machine name of the date format.

string $langcode: The langcode of the language to use.

Return value

\Drupal\Core\Datetime\DateFormatInterface|null The configuration entity for the date format in the given language for non-custom formats, NULL otherwise.

1 call to DateTimeExport::getDateFormat()
DateTimeExport::massageExportPropertyValue in src/Plugin/FieldTypeExport/DateTimeExport.php
Massage the field item property value to CSV value.

File

src/Plugin/FieldTypeExport/DateTimeExport.php, line 137

Class

DateTimeExport
Defines a Datetime field type export plugin.

Namespace

Drupal\entity_export_csv\Plugin\FieldTypeExport

Code

protected function getDateFormat($format, $langcode) {
  if (!isset($this->dateFormats[$format][$langcode])) {
    $original_language = $this->languageManager
      ->getConfigOverrideLanguage();
    $this->languageManager
      ->setConfigOverrideLanguage(new Language([
      'id' => $langcode,
    ]));
    $this->dateFormats[$format][$langcode] = $this->entityTypeManager
      ->getStorage('date_format')
      ->load($format);
    $this->languageManager
      ->setConfigOverrideLanguage($original_language);
  }
  return $this->dateFormats[$format][$langcode];
}