You are here

protected function DateRangeExport::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.

Throws

\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException

\Drupal\Component\Plugin\Exception\PluginNotFoundException

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

File

src/Plugin/FieldTypeExport/DateRangeExport.php, line 146

Class

DateRangeExport
Defines a Date range 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];
}