Commit 5783e08f authored by alexpott's avatar alexpott

Issue #2149197 by penyaskito, mikey_p, vijaycs85, herom: Replace...

Issue #2149197 by penyaskito, mikey_p, vijaycs85, herom: Replace format_interval with \Drupal::service('date')->formatInterval().
parent 0872feb1
...@@ -319,9 +319,9 @@ function _batch_process() { ...@@ -319,9 +319,9 @@ function _batch_process() {
'@total' => $total, '@total' => $total,
'@current' => floor($current), '@current' => floor($current),
'@percentage' => $percentage, '@percentage' => $percentage,
'@elapsed' => format_interval($elapsed / 1000), '@elapsed' => \Drupal::service('date')->formatInterval($elapsed / 1000),
// If possible, estimate remaining processing time. // If possible, estimate remaining processing time.
'@estimate' => ($current > 0) ? format_interval(($elapsed * ($total - $current) / $current) / 1000) : '-', '@estimate' => ($current > 0) ? \Drupal::service('date')->formatInterval(($elapsed * ($total - $current) / $current) / 1000) : '-',
); );
$message = strtr($progress_message, $values); $message = strtr($progress_message, $values);
if (!empty($task_message)) { if (!empty($task_message)) {
...@@ -410,7 +410,7 @@ function _batch_finished() { ...@@ -410,7 +410,7 @@ function _batch_finished() {
if (is_callable($batch_set['finished'])) { if (is_callable($batch_set['finished'])) {
$queue = _batch_queue($batch_set); $queue = _batch_queue($batch_set);
$operations = $queue->getAllItems(); $operations = $queue->getAllItems();
call_user_func_array($batch_set['finished'], array($batch_set['success'], $batch_set['results'], $operations, format_interval($batch_set['elapsed'] / 1000))); call_user_func_array($batch_set['finished'], array($batch_set['success'], $batch_set['results'], $operations, \Drupal::service('date')->formatInterval($batch_set['elapsed'] / 1000)));
} }
} }
} }
......
...@@ -33,7 +33,7 @@ function template_preprocess_aggregator_item(&$variables) { ...@@ -33,7 +33,7 @@ function template_preprocess_aggregator_item(&$variables) {
$variables['source_title'] = String::checkPlain($item->ftitle); $variables['source_title'] = String::checkPlain($item->ftitle);
} }
if (date('Ymd', $item->getPostedTime()) == date('Ymd')) { if (date('Ymd', $item->getPostedTime()) == date('Ymd')) {
$variables['source_date'] = t('%ago ago', array('%ago' => format_interval(REQUEST_TIME - $item->getPostedTime()))); $variables['source_date'] = t('%ago ago', array('%ago' => \Drupal::service('date')->formatInterval(REQUEST_TIME - $item->getPostedTime())));
} }
else { else {
$variables['source_date'] = format_date($item->getPostedTime(), 'medium'); $variables['source_date'] = format_date($item->getPostedTime(), 'medium');
...@@ -121,7 +121,7 @@ function template_preprocess_aggregator_summary_item(&$variables) { ...@@ -121,7 +121,7 @@ function template_preprocess_aggregator_summary_item(&$variables) {
'datetime' => format_date($item->getPostedTime(), 'html_datetime', '', 'UTC'), 'datetime' => format_date($item->getPostedTime(), 'html_datetime', '', 'UTC'),
'class' => array('feed-item-age',), 'class' => array('feed-item-age',),
), ),
'#text' => t('%age old', array('%age' => format_interval(REQUEST_TIME - $item->getPostedTime()))), '#text' => t('%age old', array('%age' => \Drupal::service('date')->formatInterval(REQUEST_TIME - $item->getPostedTime()))),
'#html' => TRUE, '#html' => TRUE,
); );
} }
...@@ -161,7 +161,7 @@ function template_preprocess_aggregator_feed_source(&$variables) { ...@@ -161,7 +161,7 @@ function template_preprocess_aggregator_feed_source(&$variables) {
$variables['source_url'] = check_url(url($feed->getWebsiteUrl(), array('absolute' => TRUE))); $variables['source_url'] = check_url(url($feed->getWebsiteUrl(), array('absolute' => TRUE)));
if ($feed->checked) { if ($feed->checked) {
$variables['last_checked'] = t('@time ago', array('@time' => format_interval(REQUEST_TIME - $feed->getLastCheckedTime()))); $variables['last_checked'] = t('@time ago', array('@time' => \Drupal::service('date')->formatInterval(REQUEST_TIME - $feed->getLastCheckedTime())));
} }
else { else {
$variables['last_checked'] = t('never'); $variables['last_checked'] = t('never');
......
...@@ -9,15 +9,43 @@ ...@@ -9,15 +9,43 @@
use Drupal\Component\Utility\Xss; use Drupal\Component\Utility\Xss;
use Drupal\Core\Controller\ControllerBase; use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Datetime\Date as DateFormatter;
use Drupal\aggregator\FeedInterface; use Drupal\aggregator\FeedInterface;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\DependencyInjection\ContainerInterface;
/** /**
* Returns responses for aggregator module routes. * Returns responses for aggregator module routes.
*/ */
class AggregatorController extends ControllerBase { class AggregatorController extends ControllerBase {
/**
* The date formatter service.
*
* @var \Drupal\Core\Datetime\Date
*/
protected $dateFormatter;
/**
* Constructs a \Drupal\aggregator\Controller\AggregatorController object.
*
* @param \Drupal\Core\Datetime\Date $date_formatter
* The date formatter service.
*/
public function __construct(DateFormatter $date_formatter) {
$this->dateFormatter = $date_formatter;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
return new static(
$container->get('date')
);
}
/** /**
* Presents the aggregator feed creation form. * Presents the aggregator feed creation form.
* *
...@@ -114,11 +142,11 @@ public function adminOverview() { ...@@ -114,11 +142,11 @@ public function adminOverview() {
foreach ($feeds as $feed) { foreach ($feeds as $feed) {
$row = array(); $row = array();
$row[] = l($feed->label(), "aggregator/sources/" . $feed->id()); $row[] = l($feed->label(), "aggregator/sources/" . $feed->id());
$row[] = format_plural($entity_manager->getStorage('aggregator_item')->getItemCount($feed), '1 item', '@count items'); $row[] = $this->dateFormatter->formatInterval($entity_manager->getStorage('aggregator_item')->getItemCount($feed), '1 item', '@count items');
$last_checked = $feed->getLastCheckedTime(); $last_checked = $feed->getLastCheckedTime();
$refresh_rate = $feed->getRefreshRate(); $refresh_rate = $feed->getRefreshRate();
$row[] = ($last_checked ? $this->t('@time ago', array('@time' => format_interval(REQUEST_TIME - $last_checked))) : $this->t('never')); $row[] = ($last_checked ? $this->t('@time ago', array('@time' => $this->dateFormatter->formatInterval(REQUEST_TIME - $last_checked))) : $this->t('never'));
$row[] = ($last_checked && $refresh_rate ? $this->t('%time left', array('%time' => format_interval($last_checked + $refresh_rate - REQUEST_TIME))) : $this->t('never')); $row[] = ($last_checked && $refresh_rate ? $this->t('%time left', array('%time' => $this->dateFormatter->formatInterval($last_checked + $refresh_rate - REQUEST_TIME))) : $this->t('never'));
$links['edit'] = array( $links['edit'] = array(
'title' => $this->t('Edit'), 'title' => $this->t('Edit'),
'route_name' => 'aggregator.feed_configure', 'route_name' => 'aggregator.feed_configure',
......
...@@ -162,7 +162,7 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { ...@@ -162,7 +162,7 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
)); ));
$intervals = array(900, 1800, 3600, 7200, 10800, 21600, 32400, 43200, 64800, 86400, 172800, 259200, 604800, 1209600, 2419200); $intervals = array(900, 1800, 3600, 7200, 10800, 21600, 32400, 43200, 64800, 86400, 172800, 259200, 604800, 1209600, 2419200);
$period = array_map('format_interval', array_combine($intervals, $intervals)); $period = array_map(array(\Drupal::service('date'), 'formatInterval'), array_combine($intervals, $intervals));
$period[AGGREGATOR_CLEAR_NEVER] = t('Never'); $period[AGGREGATOR_CLEAR_NEVER] = t('Never');
$fields['refresh'] = FieldDefinition::create('list_integer') $fields['refresh'] = FieldDefinition::create('list_integer')
......
...@@ -68,7 +68,7 @@ public function getFormId() { ...@@ -68,7 +68,7 @@ public function getFormId() {
*/ */
public function buildForm(array $form, array &$form_state) { public function buildForm(array $form, array &$form_state) {
$intervals = array(900, 1800, 3600, 7200, 10800, 21600, 32400, 43200, 64800, 86400, 172800, 259200, 604800, 1209600, 2419200); $intervals = array(900, 1800, 3600, 7200, 10800, 21600, 32400, 43200, 64800, 86400, 172800, 259200, 604800, 1209600, 2419200);
$period = array_map('format_interval', array_combine($intervals, $intervals)); $period = array_map(array(\Drupal::service('date'), 'formatInterval'), array_combine($intervals, $intervals));
$form['upload'] = array( $form['upload'] = array(
'#type' => 'file', '#type' => 'file',
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
use Drupal\aggregator\FeedInterface; use Drupal\aggregator\FeedInterface;
use Drupal\Core\Database\Database; use Drupal\Core\Database\Database;
use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Datetime\Date as DateFormatter;
use Drupal\Core\Entity\Query\QueryInterface; use Drupal\Core\Entity\Query\QueryInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerInterface;
...@@ -51,6 +52,13 @@ class DefaultProcessor extends AggregatorPluginSettingsBase implements Processor ...@@ -51,6 +52,13 @@ class DefaultProcessor extends AggregatorPluginSettingsBase implements Processor
*/ */
protected $itemStorage; protected $itemStorage;
/**
* The date formatter service.
*
* @var \Drupal\Core\Datetime\Date
*/
protected $dateFormatter;
/** /**
* Constructs a DefaultProcessor object. * Constructs a DefaultProcessor object.
* *
...@@ -66,11 +74,14 @@ class DefaultProcessor extends AggregatorPluginSettingsBase implements Processor ...@@ -66,11 +74,14 @@ class DefaultProcessor extends AggregatorPluginSettingsBase implements Processor
* The entity query object for feed items. * The entity query object for feed items.
* @param \Drupal\aggregator\ItemStorageInterface $item_storage * @param \Drupal\aggregator\ItemStorageInterface $item_storage
* The entity storage for feed items. * The entity storage for feed items.
* @param \Drupal\Core\Datetime\Date $date_formatter
* The date formatter service.
*/ */
public function __construct(array $configuration, $plugin_id, $plugin_definition, ConfigFactoryInterface $config, QueryInterface $item_query, ItemStorageInterface $item_storage) { public function __construct(array $configuration, $plugin_id, $plugin_definition, ConfigFactoryInterface $config, QueryInterface $item_query, ItemStorageInterface $item_storage, DateFormatter $date_formatter) {
$this->configFactory = $config; $this->configFactory = $config;
$this->itemStorage = $item_storage; $this->itemStorage = $item_storage;
$this->itemQuery = $item_query; $this->itemQuery = $item_query;
$this->dateFormatter = $date_formatter;
// @todo Refactor aggregator plugins to ConfigEntity so merging // @todo Refactor aggregator plugins to ConfigEntity so merging
// the configuration here is not needed. // the configuration here is not needed.
parent::__construct($configuration + $this->getConfiguration(), $plugin_id, $plugin_definition); parent::__construct($configuration + $this->getConfiguration(), $plugin_id, $plugin_definition);
...@@ -86,7 +97,8 @@ public static function create(ContainerInterface $container, array $configuratio ...@@ -86,7 +97,8 @@ public static function create(ContainerInterface $container, array $configuratio
$plugin_definition, $plugin_definition,
$container->get('config.factory'), $container->get('config.factory'),
$container->get('entity.query')->get('aggregator_item'), $container->get('entity.query')->get('aggregator_item'),
$container->get('entity.manager')->getStorage('aggregator_item') $container->get('entity.manager')->getStorage('aggregator_item'),
$container->get('date')
); );
} }
...@@ -98,10 +110,10 @@ public function buildConfigurationForm(array $form, array &$form_state) { ...@@ -98,10 +110,10 @@ public function buildConfigurationForm(array $form, array &$form_state) {
$info = $this->getPluginDefinition(); $info = $this->getPluginDefinition();
$counts = array(3, 5, 10, 15, 20, 25); $counts = array(3, 5, 10, 15, 20, 25);
$items = array_map(function ($count) { $items = array_map(function ($count) {
return format_plural($count, '1 item', '@count items'); return $this->dateFormatter->formatInterval($count, '1 item', '@count items');
}, array_combine($counts, $counts)); }, array_combine($counts, $counts));
$intervals = array(3600, 10800, 21600, 32400, 43200, 86400, 172800, 259200, 604800, 1209600, 2419200, 4838400, 9676800); $intervals = array(3600, 10800, 21600, 32400, 43200, 86400, 172800, 259200, 604800, 1209600, 2419200, 4838400, 9676800);
$period = array_map('format_interval', array_combine($intervals, $intervals)); $period = array_map(array($this->dateFormatter, 'formatInterval'), array_combine($intervals, $intervals));
$period[AGGREGATOR_CLEAR_NEVER] = t('Never'); $period[AGGREGATOR_CLEAR_NEVER] = t('Never');
$form['processors'][$info['id']] = array(); $form['processors'][$info['id']] = array();
......
...@@ -65,7 +65,6 @@ public function label() { ...@@ -65,7 +65,6 @@ public function label() {
*/ */
public function __construct(array $configuration, $plugin_id, $plugin_definition) { public function __construct(array $configuration, $plugin_id, $plugin_definition) {
parent::__construct($configuration, $plugin_id, $plugin_definition); parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->setConfiguration($configuration); $this->setConfiguration($configuration);
} }
...@@ -227,7 +226,7 @@ public function buildConfigurationForm(array $form, array &$form_state) { ...@@ -227,7 +226,7 @@ public function buildConfigurationForm(array $form, array &$form_state) {
// Identical options to the ones for page caching. // Identical options to the ones for page caching.
// @see \Drupal\system\Form\PerformanceForm::buildForm() // @see \Drupal\system\Form\PerformanceForm::buildForm()
$period = array(0, 60, 180, 300, 600, 900, 1800, 2700, 3600, 10800, 21600, 32400, 43200, 86400); $period = array(0, 60, 180, 300, 600, 900, 1800, 2700, 3600, 10800, 21600, 32400, 43200, 86400);
$period = array_map('format_interval', array_combine($period, $period)); $period = array_map(array(\Drupal::service('date'), 'formatInterval'), array_combine($period, $period));
$period[0] = '<' . t('no caching') . '>'; $period[0] = '<' . t('no caching') . '>';
$period[\Drupal\Core\Cache\Cache::PERMANENT] = t('Forever'); $period[\Drupal\Core\Cache\Cache::PERMANENT] = t('Forever');
$form['cache'] = array( $form['cache'] = array(
......
...@@ -61,7 +61,7 @@ public function testBlockInterface() { ...@@ -61,7 +61,7 @@ public function testBlockInterface() {
$definition = $display_block->getPluginDefinition(); $definition = $display_block->getPluginDefinition();
$period = array(0, 60, 180, 300, 600, 900, 1800, 2700, 3600, 10800, 21600, 32400, 43200, 86400); $period = array(0, 60, 180, 300, 600, 900, 1800, 2700, 3600, 10800, 21600, 32400, 43200, 86400);
$period = array_map('format_interval', array_combine($period, $period)); $period = array_map(array(\Drupal::service('date'), 'formatInterval'), array_combine($period, $period));
$period[0] = '<' . t('no caching') . '>'; $period[0] = '<' . t('no caching') . '>';
$period[\Drupal\Core\Cache\Cache::PERMANENT] = t('Forever'); $period[\Drupal\Core\Cache\Cache::PERMANENT] = t('Forever');
$contexts = \Drupal::service("cache_contexts")->getLabels(); $contexts = \Drupal::service("cache_contexts")->getLabels();
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
use Drupal\comment\CommentInterface; use Drupal\comment\CommentInterface;
use Drupal\comment\CommentStorageInterface; use Drupal\comment\CommentStorageInterface;
use Drupal\Component\Utility\Unicode; use Drupal\Component\Utility\Unicode;
use Drupal\Core\Datetime\Date; use Drupal\Core\Datetime\Date as DateFormatter;
use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Entity\EntityManagerInterface;
use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Form\FormBase; use Drupal\Core\Form\FormBase;
...@@ -36,11 +36,11 @@ class CommentAdminOverview extends FormBase { ...@@ -36,11 +36,11 @@ class CommentAdminOverview extends FormBase {
protected $commentStorage; protected $commentStorage;
/** /**
* Date service object. * The date formatter service.
* *
* @var \Drupal\Core\Datetime\Date * @var \Drupal\Core\Datetime\Date
*/ */
protected $date; protected $dateFormatter;
/** /**
* The module handler. * The module handler.
...@@ -56,15 +56,15 @@ class CommentAdminOverview extends FormBase { ...@@ -56,15 +56,15 @@ class CommentAdminOverview extends FormBase {
* The entity manager service. * The entity manager service.
* @param \Drupal\comment\CommentStorageInterface $comment_storage * @param \Drupal\comment\CommentStorageInterface $comment_storage
* The comment storage. * The comment storage.
* @param \Drupal\Core\Datetime\Date $date * @param \Drupal\Core\Datetime\Date $date_formatter
* The date service. * The date formatter service.
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
* The module handler. * The module handler.
*/ */
public function __construct(EntityManagerInterface $entity_manager, CommentStorageInterface $comment_storage, Date $date, ModuleHandlerInterface $module_handler) { public function __construct(EntityManagerInterface $entity_manager, CommentStorageInterface $comment_storage, DateFormatter $date_formatter, ModuleHandlerInterface $module_handler) {
$this->entityManager = $entity_manager; $this->entityManager = $entity_manager;
$this->commentStorage = $comment_storage; $this->commentStorage = $comment_storage;
$this->date = $date; $this->dateFormatter = $date_formatter;
$this->moduleHandler = $module_handler; $this->moduleHandler = $module_handler;
} }
...@@ -209,7 +209,7 @@ public function buildForm(array $form, array &$form_state, $type = 'new') { ...@@ -209,7 +209,7 @@ public function buildForm(array $form, array &$form_state, $type = 'new') {
'#access' => $commented_entity->access('view'), '#access' => $commented_entity->access('view'),
) + $commented_entity->urlInfo()->toRenderArray(), ) + $commented_entity->urlInfo()->toRenderArray(),
), ),
'changed' => $this->date->format($comment->getChangedTime(), 'short'), 'changed' => $this->dateFormatter->format($comment->getChangedTime(), 'short'),
); );
$comment_uri_options = $comment->urlInfo()->getOptions(); $comment_uri_options = $comment->urlInfo()->getOptions();
$links = array(); $links = array();
......
...@@ -59,8 +59,8 @@ function testCommentTokenReplacement() { ...@@ -59,8 +59,8 @@ function testCommentTokenReplacement() {
$tests['[comment:body]'] = $comment->comment_body->processed; $tests['[comment:body]'] = $comment->comment_body->processed;
$tests['[comment:url]'] = url('comment/' . $comment->id(), $url_options + array('fragment' => 'comment-' . $comment->id())); $tests['[comment:url]'] = url('comment/' . $comment->id(), $url_options + array('fragment' => 'comment-' . $comment->id()));
$tests['[comment:edit-url]'] = url('comment/' . $comment->id() . '/edit', $url_options); $tests['[comment:edit-url]'] = url('comment/' . $comment->id() . '/edit', $url_options);
$tests['[comment:created:since]'] = format_interval(REQUEST_TIME - $comment->getCreatedTime(), 2, $language_interface->id); $tests['[comment:created:since]'] = \Drupal::service('date')->formatInterval(REQUEST_TIME - $comment->getCreatedTime(), 2, $language_interface->id);
$tests['[comment:changed:since]'] = format_interval(REQUEST_TIME - $comment->getChangedTime(), 2, $language_interface->id); $tests['[comment:changed:since]'] = \Drupal::service('date')->formatInterval(REQUEST_TIME - $comment->getChangedTime(), 2, $language_interface->id);
$tests['[comment:parent:cid]'] = $comment->hasParentComment() ? $comment->getParentComment()->id() : NULL; $tests['[comment:parent:cid]'] = $comment->hasParentComment() ? $comment->getParentComment()->id() : NULL;
$tests['[comment:parent:title]'] = String::checkPlain($parent_comment->getSubject()); $tests['[comment:parent:title]'] = String::checkPlain($parent_comment->getSubject());
$tests['[comment:node:nid]'] = $comment->getCommentedEntityId(); $tests['[comment:node:nid]'] = $comment->getCommentedEntityId();
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
namespace Drupal\contact\Controller; namespace Drupal\contact\Controller;
use Drupal\Core\Controller\ControllerBase; use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Datetime\Date as DateFormatter;
use Drupal\Core\Flood\FloodInterface; use Drupal\Core\Flood\FloodInterface;
use Drupal\contact\CategoryInterface; use Drupal\contact\CategoryInterface;
use Drupal\user\UserInterface; use Drupal\user\UserInterface;
...@@ -28,14 +29,24 @@ class ContactController extends ControllerBase { ...@@ -28,14 +29,24 @@ class ContactController extends ControllerBase {
*/ */
protected $flood; protected $flood;
/**
* The date formatter service.
*
* @var \Drupal\Core\Datetime\Date
*/
protected $dateFormatter;
/** /**
* Constructs a ContactController object. * Constructs a ContactController object.
* *
* @param \Drupal\Core\Flood\FloodInterface $flood * @param \Drupal\Core\Flood\FloodInterface $flood
* The flood service. * The flood service.
* @param \Drupal\Core\Datetime\Date $date_formatter
* The date service.
*/ */
public function __construct(FloodInterface $flood) { public function __construct(FloodInterface $flood, DateFormatter $date_formatter) {
$this->flood = $flood; $this->flood = $flood;
$this->dateFormatter = $date_formatter;
} }
/** /**
...@@ -43,7 +54,8 @@ public function __construct(FloodInterface $flood) { ...@@ -43,7 +54,8 @@ public function __construct(FloodInterface $flood) {
*/ */
public static function create(ContainerInterface $container) { public static function create(ContainerInterface $container) {
return new static( return new static(
$container->get('flood') $container->get('flood'),
$container->get('date')
); );
} }
...@@ -131,7 +143,7 @@ protected function contactFloodControl() { ...@@ -131,7 +143,7 @@ protected function contactFloodControl() {
if (!$this->flood->isAllowed('contact', $limit, $interval)) { if (!$this->flood->isAllowed('contact', $limit, $interval)) {
drupal_set_message($this->t('You cannot send more than %limit messages in @interval. Try again later.', array( drupal_set_message($this->t('You cannot send more than %limit messages in @interval. Try again later.', array(
'%limit' => $limit, '%limit' => $limit,
'@interval' => format_interval($interval), '@interval' => $this->dateFormatter->formatInterval($interval),
)), 'error'); )), 'error');
throw new AccessDeniedHttpException(); throw new AccessDeniedHttpException();
} }
......
...@@ -209,7 +209,7 @@ function testPersonalContactFlood() { ...@@ -209,7 +209,7 @@ function testPersonalContactFlood() {
// Submit contact form one over limit. // Submit contact form one over limit.
$this->drupalGet('user/' . $this->contact_user->id(). '/contact'); $this->drupalGet('user/' . $this->contact_user->id(). '/contact');
$this->assertRaw(t('You cannot send more than %number messages in @interval. Try again later.', array('%number' => $flood_limit, '@interval' => format_interval(\Drupal::config('contact.settings')->get('flood.interval')))), 'Normal user denied access to flooded contact form.'); $this->assertRaw(t('You cannot send more than %number messages in @interval. Try again later.', array('%number' => $flood_limit, '@interval' => \Drupal::service('date')->formatInterval(\Drupal::config('contact.settings')->get('flood.interval')))), 'Normal user denied access to flooded contact form.');
// Test that the admin user can still access the contact form even though // Test that the admin user can still access the contact form even though
// the flood limit was reached. // the flood limit was reached.
......
...@@ -212,7 +212,7 @@ function testSiteWideContact() { ...@@ -212,7 +212,7 @@ function testSiteWideContact() {
// Submit contact form one over limit. // Submit contact form one over limit.
$this->drupalGet('contact'); $this->drupalGet('contact');
$this->assertResponse(403); $this->assertResponse(403);
$this->assertRaw(t('You cannot send more than %number messages in @interval. Try again later.', array('%number' => \Drupal::config('contact.settings')->get('flood.limit'), '@interval' => format_interval(600)))); $this->assertRaw(t('You cannot send more than %number messages in @interval. Try again later.', array('%number' => \Drupal::config('contact.settings')->get('flood.limit'), '@interval' => \Drupal::service('date')->formatInterval(600))));
// Test listing controller. // Test listing controller.
$this->drupalLogin($admin_user); $this->drupalLogin($admin_user);
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
namespace Drupal\datetime\Plugin\Field\FieldFormatter; namespace Drupal\datetime\Plugin\Field\FieldFormatter;
use Drupal\Core\Datetime\Date; use Drupal\Core\Datetime\Date as DateFormatter;
use Drupal\Core\Datetime\DrupalDateTime; use Drupal\Core\Datetime\DrupalDateTime;
use Drupal\Core\Entity\EntityStorageInterface; use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Field\FieldDefinitionInterface;
...@@ -39,11 +39,11 @@ public static function defaultSettings() { ...@@ -39,11 +39,11 @@ public static function defaultSettings() {
} }
/** /**
* The date service. * The date formatter service.
* *
* @var \Drupal\Core\Datetime\Date * @var \Drupal\Core\Datetime\Date
*/ */
protected $dateService; protected $dateFormatter;
/** /**
* The date storage. * The date storage.
...@@ -69,15 +69,15 @@ public static function defaultSettings() { ...@@ -69,15 +69,15 @@ public static function defaultSettings() {
* The view mode. * The view mode.
* @param array $third_party_settings * @param array $third_party_settings
* Third party settings. * Third party settings.
* @param \Drupal\Core\Datetime\Date $date_service * @param \Drupal\Core\Datetime\Date $date_formatter
* The date service. * The date formatter service.
* @param \Drupal\Core\Entity\EntityStorageInterface $date_storage * @param \Drupal\Core\Entity\EntityStorageInterface $date_storage
* The date storage. * The date storage.
*/ */
public function __construct($plugin_id, $plugin_definition, FieldDefinitionInterface $field_definition, array $settings, $label, $view_mode, array $third_party_settings, Date $date_service, EntityStorageInterface $date_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_storage) {
parent::__construct($plugin_id, $plugin_definition, $field_definition, $settings, $label, $view_mode, $third_party_settings); parent::__construct($plugin_id, $plugin_definition, $field_definition, $settings, $label, $view_mode, $third_party_settings);
$this->dateService = $date_service; $this->dateFormatter = $date_formatter;
$this->dateStorage = $date_storage; $this->dateStorage = $date_storage;
} }
...@@ -156,7 +156,7 @@ public function viewElements(FieldItemListInterface $items) { ...@@ -156,7 +156,7 @@ public function viewElements(FieldItemListInterface $items) {
*/ */
function dateFormat($date) { function dateFormat($date) {
$format_type = $this->getSetting('format_type'); $format_type = $this->getSetting('format_type');
return $this->dateService->format($date->getTimestamp(), $format_type); return $this->dateFormatter->format($date->getTimestamp(), $format_type);
}