You are here

public function Date::formatters in Display Suite 8.4

Same name and namespace in other branches
  1. 8.2 src/Plugin/DsField/Date.php \Drupal\ds\Plugin\DsField\Date::formatters()
  2. 8.3 src/Plugin/DsField/Date.php \Drupal\ds\Plugin\DsField\Date::formatters()

Returns a list of possible formatters for this field.

Return value

array A list of possible formatters.

Overrides DsFieldBase::formatters

File

src/Plugin/DsField/Date.php, line 77

Class

Date
The base plugin to create DS post date plugins.

Namespace

Drupal\ds\Plugin\DsField

Code

public function formatters() {
  $date_types = $this->entityTypeManager
    ->getStorage('date_format')
    ->loadMultiple();
  $date_formatters = [];
  foreach ($date_types as $machine_name => $entity) {

    /* @var $entity \Drupal\Core\Datetime\DateFormatterInterface */
    if ($entity
      ->isLocked()) {
      continue;
    }
    $date_formatters['ds_post_date_' . $machine_name] = $entity
      ->label() . ' (' . $this->dateFormatter
      ->format($this->timeService
      ->getRequestTime(), $entity
      ->id()) . ')';
  }
  return $date_formatters;
}