Commit 641eb3f8 authored by alexpott's avatar alexpott

Issue #2571647 by mpdonadio, joelpittet, pjonckiere: Create DateFormatterInterface

parent 458f5bee
......@@ -21,7 +21,7 @@
*
* @ingroup i18n
*/
class DateFormatter {
class DateFormatter implements DateFormatterInterface {
use StringTranslationTrait;
/**
......@@ -104,34 +104,7 @@ public function __construct(EntityManagerInterface $entity_manager, LanguageMana
}
/**
* Formats a date, using a date type or a custom date format string.
*
* @param int $timestamp
* A UNIX timestamp to format.
* @param string $type
* (optional) The format to use, one of:
* - One of the built-in formats: 'short', 'medium',
* 'long', 'html_datetime', 'html_date', 'html_time',
* 'html_yearless_date', 'html_week', 'html_month', 'html_year'.
* - The name of a date type defined by a date format config entity.
* - The machine name of an administrator-defined date format.
* - 'custom', to use $format.
* Defaults to 'medium'.
* @param string $format
* (optional) If $type is 'custom', a PHP date format string suitable for
* input to date(). Use a backslash to escape ordinary text, so it does not
* get interpreted as date format characters.
* @param string|null $timezone
* (optional) Time zone identifier, as described at
* http://php.net/manual/timezones.php Defaults to the time zone used to
* display the page.
* @param string|null $langcode
* (optional) Language code to translate to. NULL (default) means to use
* the user interface language for the page.
*
* @return string
* A translated date string in the requested format. Since the format may
* contain user input, this value should be escaped when output.
* {@inheritdoc}
*/
public function format($timestamp, $type = 'medium', $format = '', $timezone = NULL, $langcode = NULL) {
if (!isset($timezone)) {
......@@ -172,28 +145,7 @@ public function format($timestamp, $type = 'medium', $format = '', $timezone = N
}
/**
* Formats a time interval with the requested granularity.
*
* Note that for intervals over 30 days, the output is approximate: a "month"
* is always exactly 30 days, and a "year" is always 365 days. It is not
* possible to make a more exact representation, given that there is only one
* input in seconds. If you are formatting an interval between two specific
* timestamps, use \Drupal\Core\Datetime\DateFormatter::formatDiff() instead.
*
* @param int $interval
* The length of the interval in seconds.
* @param int $granularity
* (optional) How many different units to display in the string (2 by
* default).
* @param string|null $langcode
* (optional) langcode: The language code for the language used to format
* the date. Defaults to NULL, which results in the user interface language
* for the page being used.
*
* @return string
* A translated string representation of the interval.
*
* @see \Drupal\Core\Datetime\DateFormatter::formatDiff()
* {@inheritdoc}
*/
public function formatInterval($interval, $granularity = 2, $langcode = NULL) {
$output = '';
......@@ -218,21 +170,7 @@ public function formatInterval($interval, $granularity = 2, $langcode = NULL) {
}
/**
* Provides values for all date formatting characters for a given timestamp.
*
* @param string|null $langcode
* (optional) Language code of the date format, if different from the site
* default language.
* @param int|null $timestamp
* (optional) The Unix timestamp to format, defaults to current time.
* @param string|null $timezone
* (optional) The timezone to use, if different from the site's default
* timezone.
*
* @return array
* An array of formatted date values, indexed by the date format character.
*
* @see date()
* {@inheritdoc}
*/
public function getSampleDateFormats($langcode = NULL, $timestamp = NULL, $timezone = NULL) {
$timestamp = $timestamp ?: time();
......@@ -245,30 +183,7 @@ public function getSampleDateFormats($langcode = NULL, $timestamp = NULL, $timez
}
/**
* Formats the time difference from the current request time to a timestamp.
*
* @param $timestamp
* A UNIX timestamp to compare against the current request time.
* @param array $options
* (optional) An associative array with additional options. The following
* keys can be used:
* - granularity: An integer value that signals how many different units to
* display in the string. Defaults to 2.
* - langcode: The language code for the language used to format the date.
* Defaults to NULL, which results in the user interface language for the
* page being used.
* - strict: A Boolean value indicating whether or not the timestamp can be
* before the current request time. If TRUE (default) and $timestamp is
* before the current request time, the result string will be "0 seconds".
* If FALSE and $timestamp is before the current request time, the result
* string will be the formatted time difference.
*
* @return string
* A translated string representation of the difference between the given
* timestamp and the current request time. This interval is always positive.
*
* @see \Drupal\Core\Datetime\DateFormatter::formatDiff()
* @see \Drupal\Core\Datetime\DateFormatter::formatTimeDiffSince()
* {@inheritdoc}
*/
public function formatTimeDiffUntil($timestamp, $options = array()) {
$request_time = $this->requestStack->getCurrentRequest()->server->get('REQUEST_TIME');
......@@ -276,30 +191,7 @@ public function formatTimeDiffUntil($timestamp, $options = array()) {
}
/**
* Formats the time difference from a timestamp to the current request time.
*
* @param $timestamp
* A UNIX timestamp to compare against the current request time.
* @param array $options
* (optional) An associative array with additional options. The following
* keys can be used:
* - granularity: An integer value that signals how many different units to
* display in the string. Defaults to 2.
* - langcode: The language code for the language used to format the date.
* Defaults to NULL, which results in the user interface language for the
* page being used.
* - strict: A Boolean value indicating whether or not the timestamp can be
* after the current request time. If TRUE (default) and $timestamp is
* after the current request time, the result string will be "0 seconds".
* If FALSE and $timestamp is after the current request time, the result
* string will be the formatted time difference.
*
* @return string
* A translated string representation of the difference between the given
* timestamp and the current request time. This interval is always positive.
*
* @see \Drupal\Core\Datetime\DateFormatter::formatDiff()
* @see \Drupal\Core\Datetime\DateFormatter::formatTimeDiffUntil()
* {@inheritdoc}
*/
public function formatTimeDiffSince($timestamp, $options = array()) {
$request_time = $this->requestStack->getCurrentRequest()->server->get('REQUEST_TIME');
......@@ -307,32 +199,7 @@ public function formatTimeDiffSince($timestamp, $options = array()) {
}
/**
* Formats a time interval between two timestamps.
*
* @param int $from
* A UNIX timestamp, defining the from date and time.
* @param int $to
* A UNIX timestamp, defining the to date and time.
* @param array $options
* (optional) An associative array with additional options. The following
* keys can be used:
* - granularity: An integer value that signals how many different units to
* display in the string. Defaults to 2.
* - langcode: The language code for the language used to format the date.
* Defaults to NULL, which results in the user interface language for the
* page being used.
* - strict: A Boolean value indicating whether or not the $from timestamp
* can be after the $to timestamp. If TRUE (default) and $from is after
* $to, the result string will be "0 seconds". If FALSE and $from is
* after $to, the result string will be the formatted time difference.
*
* @return string
* A translated string representation of the interval. This interval is
* always positive.
*
* @see \Drupal\Core\Datetime\DateFormatter::formatInterval()
* @see \Drupal\Core\Datetime\DateFormatter::formatTimeDiffSince()
* @see \Drupal\Core\Datetime\DateFormatter::formatTimeDiffUntil()
* {@inheritdoc}
*/
public function formatDiff($from, $to, $options = array()) {
......
<?php
/**
* @file
* Contains \Drupal\Core\Datetime\DateFormatterInterface.
*/
namespace Drupal\Core\Datetime;
/**
* Provides an interface defining a date formatter.
*/
interface DateFormatterInterface {
/**
* Formats a date, using a date type or a custom date format string.
*
* @param int $timestamp
* A UNIX timestamp to format.
* @param string $type
* (optional) The format to use, one of:
* - One of the built-in formats: 'short', 'medium',
* 'long', 'html_datetime', 'html_date', 'html_time',
* 'html_yearless_date', 'html_week', 'html_month', 'html_year'.
* - The name of a date type defined by a date format config entity.
* - The machine name of an administrator-defined date format.
* - 'custom', to use $format.
* Defaults to 'medium'.
* @param string $format
* (optional) If $type is 'custom', a PHP date format string suitable for
* input to date(). Use a backslash to escape ordinary text, so it does not
* get interpreted as date format characters.
* @param string|null $timezone
* (optional) Time zone identifier, as described at
* http://php.net/manual/timezones.php Defaults to the time zone used to
* display the page.
* @param string|null $langcode
* (optional) Language code to translate to. NULL (default) means to use
* the user interface language for the page.
*
* @return string
* A translated date string in the requested format. Since the format may
* contain user input, this value should be escaped when output.
*/
public function format($timestamp, $type = 'medium', $format = '', $timezone = NULL, $langcode = NULL);
/**
* Formats a time interval with the requested granularity.
*
* Note that for intervals over 30 days, the output is approximate: a "month"
* is always exactly 30 days, and a "year" is always 365 days. It is not
* possible to make a more exact representation, given that there is only one
* input in seconds. If you are formatting an interval between two specific
* timestamps, use \Drupal\Core\Datetime\DateFormatter::formatDiff() instead.
*
* @param int $interval
* The length of the interval in seconds.
* @param int $granularity
* (optional) How many different units to display in the string (2 by
* default).
* @param string|null $langcode
* (optional) langcode: The language code for the language used to format
* the date. Defaults to NULL, which results in the user interface language
* for the page being used.
*
* @return string
* A translated string representation of the interval.
*
* @see \Drupal\Core\Datetime\DateFormatterInterface::formatDiff()
*/
public function formatInterval($interval, $granularity = 2, $langcode = NULL);
/**
* Provides values for all date formatting characters for a given timestamp.
*
* @param string|null $langcode
* (optional) Language code of the date format, if different from the site
* default language.
* @param int|null $timestamp
* (optional) The Unix timestamp to format, defaults to current time.
* @param string|null $timezone
* (optional) The timezone to use, if different from the site's default
* timezone.
*
* @return array
* An array of formatted date values, indexed by the date format character.
*
* @see date()
*/
public function getSampleDateFormats($langcode = NULL, $timestamp = NULL, $timezone = NULL);
/**
* Formats the time difference from the current request time to a timestamp.
*
* @param $timestamp
* A UNIX timestamp to compare against the current request time.
* @param array $options
* (optional) An associative array with additional options. The following
* keys can be used:
* - granularity: An integer value that signals how many different units to
* display in the string. Defaults to 2.
* - langcode: The language code for the language used to format the date.
* Defaults to NULL, which results in the user interface language for the
* page being used.
* - strict: A Boolean value indicating whether or not the timestamp can be
* before the current request time. If TRUE (default) and $timestamp is
* before the current request time, the result string will be "0 seconds".
* If FALSE and $timestamp is before the current request time, the result
* string will be the formatted time difference.
*
* @return string
* A translated string representation of the difference between the given
* timestamp and the current request time. This interval is always positive.
*
* @see \Drupal\Core\Datetime\DateFormatterInterface::formatDiff()
* @see \Drupal\Core\Datetime\DateFormatterInterface::formatTimeDiffSince()
*/
public function formatTimeDiffUntil($timestamp, $options = array());
/**
* Formats the time difference from a timestamp to the current request time.
*
* @param $timestamp
* A UNIX timestamp to compare against the current request time.
* @param array $options
* (optional) An associative array with additional options. The following
* keys can be used:
* - granularity: An integer value that signals how many different units to
* display in the string. Defaults to 2.
* - langcode: The language code for the language used to format the date.
* Defaults to NULL, which results in the user interface language for the
* page being used.
* - strict: A Boolean value indicating whether or not the timestamp can be
* after the current request time. If TRUE (default) and $timestamp is
* after the current request time, the result string will be "0 seconds".
* If FALSE and $timestamp is after the current request time, the result
* string will be the formatted time difference.
*
* @return string
* A translated string representation of the difference between the given
* timestamp and the current request time. This interval is always positive.
*
* @see \Drupal\Core\Datetime\DateFormatterInterface::formatDiff()
* @see \Drupal\Core\Datetime\DateFormatterInterface::formatTimeDiffUntil()
*/
public function formatTimeDiffSince($timestamp, $options = array());
/**
* Formats a time interval between two timestamps.
*
* @param int $from
* A UNIX timestamp, defining the from date and time.
* @param int $to
* A UNIX timestamp, defining the to date and time.
* @param array $options
* (optional) An associative array with additional options. The following
* keys can be used:
* - granularity: An integer value that signals how many different units to
* display in the string. Defaults to 2.
* - langcode: The language code for the language used to format the date.
* Defaults to NULL, which results in the user interface language for the
* page being used.
* - strict: A Boolean value indicating whether or not the $from timestamp
* can be after the $to timestamp. If TRUE (default) and $from is after
* $to, the result string will be "0 seconds". If FALSE and $from is
* after $to, the result string will be the formatted time difference.
*
* @return string
* A translated string representation of the interval. This interval is
* always positive.
*
* @see \Drupal\Core\Datetime\DateFormatterInterface::formatInterval()
* @see \Drupal\Core\Datetime\DateFormatterInterface::formatTimeDiffSince()
* @see \Drupal\Core\Datetime\DateFormatterInterface::formatTimeDiffUntil()
*/
public function formatDiff($from, $to, $options = array());
}
......@@ -8,7 +8,7 @@
namespace Drupal\Core\Field\Plugin\Field\FieldFormatter;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Core\Datetime\DateFormatter;
use Drupal\Core\Datetime\DateFormatterInterface;
use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\Field\FormatterBase;
......@@ -35,7 +35,7 @@ class TimestampAgoFormatter extends FormatterBase implements ContainerFactoryPlu
/**
* The date formatter service.
*
* @var \Drupal\Core\Datetime\DateFormatter
* @var \Drupal\Core\Datetime\DateFormatterInterface
*/
protected $dateFormatter;
......@@ -63,12 +63,12 @@ class TimestampAgoFormatter extends FormatterBase implements ContainerFactoryPlu
* The view mode.
* @param array $third_party_settings
* Any third party settings.
* @param \Drupal\Core\Datetime\DateFormatter $date_formatter
* @param \Drupal\Core\Datetime\DateFormatterInterface $date_formatter
* The date formatter service.
* @param \Symfony\Component\HttpFoundation\Request $request
* The current request.
*/
public function __construct($plugin_id, $plugin_definition, FieldDefinitionInterface $field_definition, array $settings, $label, $view_mode, array $third_party_settings, DateFormatter $date_formatter, Request $request) {
public function __construct($plugin_id, $plugin_definition, FieldDefinitionInterface $field_definition, array $settings, $label, $view_mode, array $third_party_settings, DateFormatterInterface $date_formatter, Request $request) {
parent::__construct($plugin_id, $plugin_definition, $field_definition, $settings, $label, $view_mode, $third_party_settings);
$this->dateFormatter = $date_formatter;
......
......@@ -7,7 +7,7 @@
namespace Drupal\Core\Field\Plugin\Field\FieldFormatter;
use Drupal\Core\Datetime\DateFormatter;
use Drupal\Core\Datetime\DateFormatterInterface;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\Core\Field\FieldItemListInterface;
......@@ -34,7 +34,7 @@ class TimestampFormatter extends FormatterBase implements ContainerFactoryPlugin
/**
* The date formatter service.
*
* @var \Drupal\Core\Datetime\DateFormatter
* @var \Drupal\Core\Datetime\DateFormatterInterface
*/
protected $dateFormatter;
......@@ -62,12 +62,12 @@ class TimestampFormatter extends FormatterBase implements ContainerFactoryPlugin
* The view mode.
* @param array $third_party_settings
* Third party settings.
* @param \Drupal\Core\Datetime\DateFormatter $date_formatter
* @param \Drupal\Core\Datetime\DateFormatterInterface $date_formatter
* The date formatter service.
* @param \Drupal\Core\Entity\EntityStorageInterface $date_format_storage
* The date format storage.
*/
public function __construct($plugin_id, $plugin_definition, FieldDefinitionInterface $field_definition, array $settings, $label, $view_mode, array $third_party_settings, DateFormatter $date_formatter, EntityStorageInterface $date_format_storage) {
public function __construct($plugin_id, $plugin_definition, FieldDefinitionInterface $field_definition, array $settings, $label, $view_mode, array $third_party_settings, DateFormatterInterface $date_formatter, EntityStorageInterface $date_format_storage) {
parent::__construct($plugin_id, $plugin_definition, $field_definition, $settings, $label, $view_mode, $third_party_settings);
$this->dateFormatter = $date_formatter;
......
......@@ -9,7 +9,7 @@
use Drupal\Component\Utility\Xss;
use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Datetime\DateFormatter;
use Drupal\Core\Datetime\DateFormatterInterface;
use Drupal\aggregator\FeedInterface;
use Drupal\Core\Url;
use Symfony\Component\HttpFoundation\Request;
......@@ -24,17 +24,17 @@ class AggregatorController extends ControllerBase {
/**
* The date formatter service.
*
* @var \Drupal\Core\Datetime\DateFormatter
* @var \Drupal\Core\Datetime\DateFormatterInterface
*/
protected $dateFormatter;
/**
* Constructs a \Drupal\aggregator\Controller\AggregatorController object.
*
* @param \Drupal\Core\Datetime\DateFormatter $date_formatter
* @param \Drupal\Core\Datetime\DateFormatterInterface $date_formatter
* The date formatter service.
*/
public function __construct(DateFormatter $date_formatter) {
public function __construct(DateFormatterInterface $date_formatter) {
$this->dateFormatter = $date_formatter;
}
......
......@@ -14,7 +14,7 @@
use Drupal\Component\Utility\Unicode;
use Drupal\Core\Database\Database;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Datetime\DateFormatter;
use Drupal\Core\Datetime\DateFormatterInterface;
use Drupal\Core\Entity\Query\QueryInterface;
use Drupal\Core\Form\ConfigFormBaseTrait;
use Drupal\Core\Form\FormStateInterface;
......@@ -61,7 +61,7 @@ class DefaultProcessor extends AggregatorPluginSettingsBase implements Processor
/**
* The date formatter service.
*
* @var \Drupal\Core\Datetime\DateFormatter
* @var \Drupal\Core\Datetime\DateFormatterInterface
*/
protected $dateFormatter;
......@@ -80,10 +80,10 @@ class DefaultProcessor extends AggregatorPluginSettingsBase implements Processor
* The entity query object for feed items.
* @param \Drupal\aggregator\ItemStorageInterface $item_storage
* The entity storage for feed items.
* @param \Drupal\Core\Datetime\DateFormatter $date_formatter
* @param \Drupal\Core\Datetime\DateFormatterInterface $date_formatter
* The date formatter service.
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition, ConfigFactoryInterface $config, QueryInterface $item_query, ItemStorageInterface $item_storage, DateFormatter $date_formatter) {
public function __construct(array $configuration, $plugin_id, $plugin_definition, ConfigFactoryInterface $config, QueryInterface $item_query, ItemStorageInterface $item_storage, DateFormatterInterface $date_formatter) {
$this->configFactory = $config;
$this->itemStorage = $item_storage;
$this->itemQuery = $item_query;
......
......@@ -10,7 +10,7 @@
use Drupal\comment\CommentInterface;
use Drupal\comment\CommentStorageInterface;
use Drupal\Component\Utility\Unicode;
use Drupal\Core\Datetime\DateFormatter;
use Drupal\Core\Datetime\DateFormatterInterface;
use Drupal\Core\Entity\EntityManagerInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Form\FormBase;
......@@ -39,7 +39,7 @@ class CommentAdminOverview extends FormBase {
/**
* The date formatter service.
*
* @var \Drupal\Core\Datetime\DateFormatter
* @var \Drupal\Core\Datetime\DateFormatterInterface
*/
protected $dateFormatter;
......@@ -57,12 +57,12 @@ class CommentAdminOverview extends FormBase {
* The entity manager service.
* @param \Drupal\comment\CommentStorageInterface $comment_storage
* The comment storage.
* @param \Drupal\Core\Datetime\DateFormatter $date_formatter
* @param \Drupal\Core\Datetime\DateFormatterInterface $date_formatter
* The date formatter service.
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
* The module handler.
*/
public function __construct(EntityManagerInterface $entity_manager, CommentStorageInterface $comment_storage, DateFormatter $date_formatter, ModuleHandlerInterface $module_handler) {
public function __construct(EntityManagerInterface $entity_manager, CommentStorageInterface $comment_storage, DateFormatterInterface $date_formatter, ModuleHandlerInterface $module_handler) {
$this->entityManager = $entity_manager;
$this->commentStorage = $comment_storage;
$this->dateFormatter = $date_formatter;
......
......@@ -18,7 +18,7 @@ class DateFormat extends FormElementBase {
* {@inheritdoc}
*/
public function getTranslationElement(LanguageInterface $translation_language, $source_config, $translation_config) {
/** @var \Drupal\Core\Datetime\DateFormatter $date_formatter */
/** @var \Drupal\Core\Datetime\DateFormatterInterface $date_formatter */
$date_formatter = \Drupal::service('date.formatter');
$description = $this->t('A user-defined date format. See the <a href=":url">PHP manual</a> for available options.', array(':url' => 'http://php.net/manual/function.date.php'));
$format = $this->t('Displayed as %date_format', array('%date_format' => $date_formatter->format(REQUEST_TIME, 'custom', $translation_config)));
......
......@@ -8,7 +8,7 @@
namespace Drupal\contact;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Core\Datetime\DateFormatter;
use Drupal\Core\Datetime\DateFormatterInterface;
use Drupal\Core\Entity\ContentEntityForm;
use Drupal\Core\Entity\EntityManagerInterface;
use Drupal\Core\Flood\FloodInterface;
......@@ -53,7 +53,7 @@ class MessageForm extends ContentEntityForm {
/**
* The date formatter service.
*
* @var \Drupal\Core\Datetime\DateFormatter
* @var \Drupal\Core\Datetime\DateFormatterInterface
*/
protected $dateFormatter;
......@@ -68,10 +68,10 @@ class MessageForm extends ContentEntityForm {
* The language manager service.
* @param \Drupal\contact\MailHandlerInterface $mail_handler
* The contact mail handler service.
* @param \Drupal\Core\Datetime\DateFormatter $date_formatter
* @param \Drupal\Core\Datetime\DateFormatterInterface $date_formatter
* The date service.
*/
public function __construct(EntityManagerInterface $entity_manager, FloodInterface $flood, LanguageManagerInterface $language_manager, MailHandlerInterface $mail_handler, DateFormatter $date_formatter) {
public function __construct(EntityManagerInterface $entity_manager, FloodInterface $flood, LanguageManagerInterface $language_manager, MailHandlerInterface $mail_handler, DateFormatterInterface $date_formatter) {
parent::__construct($entity_manager);
$this->flood = $flood;
$this->languageManager = $language_manager;
......
......@@ -7,7 +7,7 @@
namespace Drupal\datetime\Plugin\Field\FieldFormatter;
use Drupal\Core\Datetime\DateFormatter;
use Drupal\Core\Datetime\DateFormatterInterface;
use Drupal\Core\Datetime\DrupalDateTime;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Field\FieldDefinitionInterface;
......@@ -25,7 +25,7 @@ abstract class DateTimeFormatterBase extends FormatterBase implements ContainerF
/**
* The date formatter service.
*
* @var \Drupal\Core\Datetime\DateFormatter
* @var \Drupal\Core\Datetime\DateFormatterInterface
*/
protected $dateFormatter;
......@@ -53,12 +53,12 @@ abstract class DateTimeFormatterBase extends FormatterBase implements ContainerF
* The view mode.
* @param array $third_party_settings
* Third party settings.
* @param \Drupal\Core\Datetime\DateFormatter $date_formatter
* @param \Drupal\Core\Datetime\DateFormatterInterface $date_formatter
* The date formatter service.
* @param \Drupal\Core\Entity\EntityStorageInterface $date_format_storage
* The date format entity storage.
*/
public function __construct($plugin_id, $plugin_definition, FieldDefinitionInterface $field_definition, array $settings, $label, $view_mode, array $third_party_settings, DateFormatter $date_formatter, EntityStorageInterface $date_format_storage) {
public function __construct($plugin_id, $plugin_definition, FieldDefinitionInterface $field_definition, array $settings, $label, $view_mode, array $third_party_settings, DateFormatterInterface $date_formatter, EntityStorageInterface $date_format_storage) {
parent::__construct($plugin_id, $plugin_definition, $field_definition, $settings, $label, $view_mode, $third_party_settings);
$this->dateFormatter = $date_formatter;
......
......@@ -8,7 +8,7 @@
namespace Drupal\datetime\Plugin\Field\FieldFormatter;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Core\Datetime\DateFormatter;
use Drupal\Core\Datetime\DateFormatterInterface;
use Drupal\Core\Datetime\DrupalDateTime;
use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\Core\Field\FieldItemListInterface;
......@@ -34,7 +34,7 @@ class DateTimeTimeAgoFormatter extends FormatterBase implements ContainerFactory
/**
* The date formatter service.
*
* @var \Drupal\Core\Datetime\DateFormatter
* @var \Drupal\Core\Datetime\DateFormatterInterface
*/
protected $dateFormatter;
......@@ -62,12 +62,12 @@ class DateTimeTimeAgoFormatter extends FormatterBase implements ContainerFactory
* The view mode.
* @param array $third_party_settings
* Third party settings.
* @param \Drupal\Core\Datetime\DateFormatter $date_formatter
* @param \Drupal\Core\Datetime\DateFormatterInterface $date_formatter
* The date formatter service.
* @param \Symfony\Component\HttpFoundation\Request $request
* The current request.
*/
public function __construct($plugin_id, $plugin_definition, FieldDefinitionInterface $field_definition, array $settings, $label, $view_mode, array $third_party_settings, DateFormatter $date_formatter, Request $request) {
public function __construct($plugin_id, $plugin_definition, FieldDefinitionInterface $field_definition, array $settings, $label, $view_mode, array $third_party_settings, DateFormatterInterface $date_formatter, Request $request) {
parent::__construct($plugin_id, $plugin_definition, $field_definition, $settings, $label, $view_mode, $third_party_settings);
$this->dateFormatter = $date_formatter;
......
......@@ -7,7 +7,7 @@
namespace Drupal\datetime\Plugin\views\filter;
use Drupal\Core\Datetime\DateFormatter;
use Drupal\Core\Datetime\DateFormatterInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\datetime\Plugin\Field\FieldType\DateTimeItem;
use Drupal\views\FieldAPIHandlerTrait;
......@@ -32,7 +32,7 @@ class Date extends NumericDate implements ContainerFactoryPluginInterface {
/**
* The date formatter service.
*
* @var \Drupal\Core\Datetime\DateFormatter
* @var \Drupal\Core\Datetime\DateFormatterInterface
*/
protected $dateFormatter;
......@@ -61,12 +61,12 @@ class Date extends NumericDate implements ContainerFactoryPluginInterface {
* The plugin ID for the plugin instance.
* @param mixed $plugin_definition
* The plugin implementation definition.
* @param \Drupal\Core\Datetime\DateFormatter $date_formatter
* @param \Drupal\Core\Datetime\DateFormatterInterface $date_formatter
* The date formatter service.
* @param \Symfony\Component\HttpFoundation\RequestStack
* The request stack used to determine the current time.
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition, DateFormatter $date_formatter, RequestStack $request_stack) {
public function __construct(array $configuration, $plugin_id, $plugin_definition, DateFormatterInterface $date_formatter, RequestStack $request_stack) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->dateFormatter = $date_formatter;
$this->requestStack = $request_stack;
......
......@@ -11,7 +11,7 @@
use Drupal\Component\Utility\Unicode;
use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Database\Connection;
use Drupal\Core\Datetime\DateFormatter;
use Drupal\Core\Datetime\DateFormatterInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Form\FormBuilderInterface;
use Drupal\Core\Logger\RfcLogLevel;
......@@ -41,7 +41,7 @@ class DbLogController extends ControllerBase {
/**
* The date formatter service.
*
* @var \Drupal\Core\Datetime\DateFormatter
* @var \Drupal\Core\Datetime\DateFormatterInterface
*/
protected $dateFormatter;
......@@ -78,12 +78,12 @@ public static function create(ContainerInterface $container) {
* A database connection.
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
* A module handler.
* @param \Drupal\Core\Datetime\DateFormatter $date_formatter
* @param \Drupal\Core\Datetime\DateFormatterInterface $date_formatter
* The date formatter service.
* @param \Drupal\Core\Form\FormBuilderInterface $form_builder
* The form builder service.
*/
public function __construct(Connection $database, ModuleHandlerInterface $module_handler, DateFormatter $date_formatter, FormBuilderInterface $form_builder) {
public function __construct(Connection $database, ModuleHandlerInterface $module_handler, DateFormatterInterface $date_formatter, FormBuilderInterface $form_builder) {
$this->database = $database;
$this->moduleHandler = $module_handler;
$this->dateFormatter = $date_formatter;
......
......@@ -9,7 +9,7 @@
use Drupal\Component\Utility\Xss;
use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Datetime\DateFormatter;
use Drupal\Core\Datetime\DateFormatterInterface;
use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
use Drupal\Core\Language\LanguageInterface;
use Drupal\Core\Render\RendererInterface;
......@@ -26,7 +26,7 @@ class NodeController extends ControllerBase implements ContainerInjectionInterfa
/**
* The date formatter service.
*