You are here

private static function SmartDateTrait::loadSmartDateFormat in Smart Date 8

Same name and namespace in other branches
  1. 8.2 src/SmartDateTrait.php \Drupal\smart_date\SmartDateTrait::loadSmartDateFormat()
  2. 3.x src/SmartDateTrait.php \Drupal\smart_date\SmartDateTrait::loadSmartDateFormat()
  3. 3.0.x src/SmartDateTrait.php \Drupal\smart_date\SmartDateTrait::loadSmartDateFormat()
  4. 3.1.x src/SmartDateTrait.php \Drupal\smart_date\SmartDateTrait::loadSmartDateFormat()
  5. 3.2.x src/SmartDateTrait.php \Drupal\smart_date\SmartDateTrait::loadSmartDateFormat()
  6. 3.3.x src/SmartDateTrait.php \Drupal\smart_date\SmartDateTrait::loadSmartDateFormat()
  7. 3.4.x src/SmartDateTrait.php \Drupal\smart_date\SmartDateTrait::loadSmartDateFormat()

Load a Smart Date Format from a format name.

Parameters

string $formatName: The machine name of a Smart Date Format.

Return value

NULL|\Drupal\smart_date\Entity\SmartDateFormatInterface A Smart Date Format configuration entity, or NULL if one with the given name could not be found.

1 call to SmartDateTrait::loadSmartDateFormat()
SmartDateDefaultFormatter::formatDate in src/Plugin/Field/FieldFormatter/SmartDateDefaultFormatter.php
Creates a formatted date value as a string.

File

src/SmartDateTrait.php, line 219

Class

SmartDateTrait
Provides friendly methods for smart date range.

Namespace

Drupal\smart_date

Code

private static function loadSmartDateFormat($formatName) {
  $format = NULL;
  $loadedFormat = \Drupal::getContainer()
    ->get('entity_type.manager')
    ->getStorage('smart_date_format')
    ->load($formatName);
  if ($format instanceof SmartDateFormatInterface) {
    $format = $loadedFormat;
  }
  return $format;
}