public function Date::formatters in Display Suite 8.4
Same name and namespace in other branches
- 8.2 src/Plugin/DsField/Date.php \Drupal\ds\Plugin\DsField\Date::formatters()
- 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\DsFieldCode
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;
}