Update to Drupal 8.1.0. For more information, see https://www.drupal.org/drupal-8.1.0-release-notes

This commit is contained in:
Pantheon Automation 2016-04-20 09:56:34 -07:00 committed by Greg Anderson
parent b11a755ba8
commit c0a0d5a94c
6920 changed files with 64395 additions and 57312 deletions

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\datetime\Plugin\Field\FieldFormatter\DateTimeCustomFormatter.
*/
namespace Drupal\datetime\Plugin\Field\FieldFormatter;
use Drupal\Core\Datetime\DrupalDateTime;
@ -84,7 +79,7 @@ class DateTimeCustomFormatter extends DateTimeFormatterBase {
$form['date_format'] = array(
'#type' => 'textfield',
'#title' => $this->t('Date/time format'),
'#description' => $this->t('See <a href=":url" target="_blank">the documentation for PHP date formats</a>.', [':url' => 'http://php.net/manual/function.date.php']),
'#description' => $this->t('See <a href="http://php.net/manual/function.date.php" target="_blank">the documentation for PHP date formats</a>.'),
'#default_value' => $this->getSetting('date_format'),
);

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\datetime\Plugin\Field\FieldFormatter\DateTimeDefaultFormatter.
*/
namespace Drupal\datetime\Plugin\Field\FieldFormatter;
use Drupal\Core\Datetime\DrupalDateTime;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\datetime\Plugin\Field\FieldFormatter\DateTimeFormatterBase.
*/
namespace Drupal\datetime\Plugin\Field\FieldFormatter;
use Drupal\Core\Datetime\DateFormatterInterface;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\datetime\Plugin\Field\FieldFormatter\DateTimePlainFormatter.
*/
namespace Drupal\datetime\Plugin\Field\FieldFormatter;
use Drupal\Core\Field\FieldItemListInterface;

View file

@ -1,13 +1,9 @@
<?php
/**
* @file
* Contains \Drupal\datetime\Plugin\Field\FieldFormatter\DateTimeTimeAgoFormatter.
*/
namespace Drupal\datetime\Plugin\Field\FieldFormatter;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Core\Cache\CacheableMetadata;
use Drupal\Core\Datetime\DateFormatterInterface;
use Drupal\Core\Datetime\DrupalDateTime;
use Drupal\Core\Field\FieldDefinitionInterface;
@ -112,7 +108,7 @@ class DateTimeTimeAgoFormatter extends FormatterBase implements ContainerFactory
foreach ($items as $delta => $item) {
$date = $item->date;
$output = '';
$output = [];
if (!empty($item->date)) {
if ($this->getFieldSetting('datetime_type') == 'date') {
// A date without time will pick up the current time, use the default.
@ -120,7 +116,7 @@ class DateTimeTimeAgoFormatter extends FormatterBase implements ContainerFactory
}
$output = $this->formatDate($date);
}
$elements[$delta] = array('#markup' => $output);
$elements[$delta] = $output;
}
return $elements;
@ -176,20 +172,31 @@ class DateTimeTimeAgoFormatter extends FormatterBase implements ContainerFactory
* @param \Drupal\Core\Datetime\DrupalDateTime|object $date
* A date/time object.
*
* @return string
* @return array
* The formatted date/time string using the past or future format setting.
*/
protected function formatDate(DrupalDateTime $date) {
$granularity = $this->getSetting('granularity');
$timestamp = $date->getTimestamp();
$options = ['granularity' => $granularity];
$options = [
'granularity' => $granularity,
'return_as_object' => TRUE,
];
if ($this->request->server->get('REQUEST_TIME') > $timestamp) {
return SafeMarkup::format($this->getSetting('past_format'), ['@interval' => $this->dateFormatter->formatTimeDiffSince($timestamp, $options)]);
$result = $this->dateFormatter->formatTimeDiffSince($timestamp, $options);
$build = [
'#markup' => SafeMarkup::format($this->getSetting('past_format'), ['@interval' => $result->getString()]),
];
}
else {
return SafeMarkup::format($this->getSetting('future_format'), ['@interval' => $this->dateFormatter->formatTimeDiffUntil($timestamp, $options)]);
$result = $this->dateFormatter->formatTimeDiffUntil($timestamp, $options);
$build = [
'#markup' => SafeMarkup::format($this->getSetting('future_format'), ['@interval' => $result->getString()]),
];
}
CacheableMetadata::createFromObject($result)->applyTo($build);
return $build;
}
}

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\datetime\Plugin\Field\FieldType\DateTimeFieldItemList.
*/
namespace Drupal\datetime\Plugin\Field\FieldType;
use Drupal\Core\Datetime\DrupalDateTime;
@ -51,7 +46,7 @@ class DateTimeFieldItemList extends FieldItemList {
'default_date' => array(
'#type' => 'textfield',
'#title' => t('Relative default value'),
'#description' => t("Describe a time by reference to the current day, like '+90 days' (90 days from the day the field is created) or '+1 Saturday' (the next Saturday). See <a href=\"@url\">@strtotime</a> for more details.", array('@strtotime' => 'strtotime', '@url' => 'http://www.php.net/manual/en/function.strtotime.php')),
'#description' => t("Describe a time by reference to the current day, like '+90 days' (90 days from the day the field is created) or '+1 Saturday' (the next Saturday). See <a href=\"http://php.net/manual/function.strtotime.php\">strtotime</a> for more details."),
'#default_value' => (isset($default_value[0]['default_date_type']) && $default_value[0]['default_date_type'] == static::DEFAULT_VALUE_CUSTOM) ? $default_value[0]['default_date'] : '',
'#states' => array(
'visible' => array(

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\datetime\Plugin\Field\FieldType\DateTimeItem.
*/
namespace Drupal\datetime\Plugin\Field\FieldType;
use Drupal\Core\Field\FieldDefinitionInterface;
@ -97,6 +92,7 @@ class DateTimeItem extends FieldItemBase {
static::DATETIME_TYPE_DATETIME => t('Date and time'),
static::DATETIME_TYPE_DATE => t('Date only'),
),
'#disabled' => $has_data,
);
return $element;

View file

@ -1,8 +1,4 @@
<?php
/**
* @file
* Contains \Drupal\datetime\Plugin\Field\FieldWidget\DateTimeDatelistWidget.
*/
namespace Drupal\datetime\Plugin\Field\FieldWidget;

View file

@ -1,8 +1,4 @@
<?php
/**
* @file
* Contains \Drupal\datetime\Plugin\Field\FieldWidget\DateTimeDefaultWidget.
*/
namespace Drupal\datetime\Plugin\Field\FieldWidget;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\datetime\Plugin\Field\FieldWidget\DateTimeWidgetBase.
*/
namespace Drupal\datetime\Plugin\Field\FieldWidget;
use Drupal\Core\Datetime\DrupalDateTime;