From da98f09262d2289a6d41831dbaad8ad055e225e4 Mon Sep 17 00:00:00 2001 From: Aakashko <Aakashko@3637478.no-reply.drupal.org> Date: Mon, 23 Mar 2020 09:25:55 -0600 Subject: [PATCH] Issue #3110896 by aakashko, owenbush: Remove all deprecated function calls for Drupal 9 --- recurring_events.tokens.inc | 2 +- src/Entity/EventSeries.php | 16 ++++++++-------- src/EventCreationService.php | 4 ++-- src/EventInstanceListBuilder.php | 2 +- src/EventSeriesListBuilder.php | 2 +- src/Form/EventInstanceDeleteForm.php | 2 +- src/Form/EventSeriesDeleteForm.php | 2 +- .../EventInstanceDateFormatter.php | 2 +- .../Field/FieldType/ConsecutiveRecurringDate.php | 4 ++-- .../Field/FieldType/DailyRecurringDate.php | 2 +- .../Field/FieldType/MonthlyRecurringDate.php | 2 +- .../Field/FieldType/WeeklyRecurringDate.php | 2 +- 12 files changed, 21 insertions(+), 21 deletions(-) diff --git a/recurring_events.tokens.inc b/recurring_events.tokens.inc index 3008e86..95dcb93 100644 --- a/recurring_events.tokens.inc +++ b/recurring_events.tokens.inc @@ -81,7 +81,7 @@ function recurring_events_tokens($type, $tokens, array $data, array $options, Bu if ($type == 'eventinstance' && !empty($data['eventinstance'])) { $event_instance = $data['eventinstance']; $date_format = \Drupal::config('recurring_events.eventinstance.config')->get('date_format'); - $timezone = new \DateTimeZone(drupal_get_user_timezone()); + $timezone = new \DateTimeZone(date_default_timezone_get()); foreach ($tokens as $name => $original) { switch ($name) { case 'title': diff --git a/src/Entity/EventSeries.php b/src/Entity/EventSeries.php index 25b8567..572f3ef 100644 --- a/src/Entity/EventSeries.php +++ b/src/Entity/EventSeries.php @@ -618,7 +618,7 @@ class EventSeries extends EditorialContentEntityBase implements EventInterface { * The date object for the consecutive start date. */ public function getConsecutiveStartDate() { - $user_timezone = new \DateTimeZone(drupal_get_user_timezone()); + $user_timezone = new \DateTimeZone(date_default_timezone_get()); if (!empty($this->get('consecutive_recurring_date')->start_date)) { return $this->get('consecutive_recurring_date')->start_date->setTimezone($user_timezone)->setTime(0, 0, 0); } @@ -632,7 +632,7 @@ class EventSeries extends EditorialContentEntityBase implements EventInterface { * The date object for the consecutive end date. */ public function getConsecutiveEndDate() { - $user_timezone = new \DateTimeZone(drupal_get_user_timezone()); + $user_timezone = new \DateTimeZone(date_default_timezone_get()); if (!empty($this->get('consecutive_recurring_date')->end_date)) { return $this->get('consecutive_recurring_date')->end_date->setTimezone($user_timezone)->setTime(0, 0, 0); } @@ -706,7 +706,7 @@ class EventSeries extends EditorialContentEntityBase implements EventInterface { * The date object for the daily start date. */ public function getDailyStartDate() { - $user_timezone = new \DateTimeZone(drupal_get_user_timezone()); + $user_timezone = new \DateTimeZone(date_default_timezone_get()); if (!empty($this->get('daily_recurring_date')->start_date)) { return $this->get('daily_recurring_date')->start_date->setTimezone($user_timezone)->setTime(0, 0, 0); } @@ -720,7 +720,7 @@ class EventSeries extends EditorialContentEntityBase implements EventInterface { * The date object for the daily end date. */ public function getDailyEndDate() { - $user_timezone = new \DateTimeZone(drupal_get_user_timezone()); + $user_timezone = new \DateTimeZone(date_default_timezone_get()); if (!empty($this->get('daily_recurring_date')->end_date)) { return $this->get('daily_recurring_date')->end_date->setTimezone($user_timezone)->setTime(0, 0, 0); } @@ -754,7 +754,7 @@ class EventSeries extends EditorialContentEntityBase implements EventInterface { * The date object for the weekly start date. */ public function getWeeklyStartDate() { - $user_timezone = new \DateTimeZone(drupal_get_user_timezone()); + $user_timezone = new \DateTimeZone(date_default_timezone_get()); if (!empty($this->get('weekly_recurring_date')->start_date)) { return $this->get('weekly_recurring_date')->start_date->setTimezone($user_timezone)->setTime(0, 0, 0); } @@ -768,7 +768,7 @@ class EventSeries extends EditorialContentEntityBase implements EventInterface { * The date object for the weekly end date. */ public function getWeeklyEndDate() { - $user_timezone = new \DateTimeZone(drupal_get_user_timezone()); + $user_timezone = new \DateTimeZone(date_default_timezone_get()); if (!empty($this->get('weekly_recurring_date')->end_date)) { return $this->get('weekly_recurring_date')->end_date->setTimezone($user_timezone)->setTime(0, 0, 0); } @@ -850,7 +850,7 @@ class EventSeries extends EditorialContentEntityBase implements EventInterface { * The date object for the monthly start date. */ public function getMonthlyStartDate() { - $user_timezone = new \DateTimeZone(drupal_get_user_timezone()); + $user_timezone = new \DateTimeZone(date_default_timezone_get()); if (!empty($this->get('monthly_recurring_date')->start_date)) { return $this->get('monthly_recurring_date')->start_date->setTimezone($user_timezone)->setTime(0, 0, 0); } @@ -864,7 +864,7 @@ class EventSeries extends EditorialContentEntityBase implements EventInterface { * The date object for the monthly end date. */ public function getMonthlyEndDate() { - $user_timezone = new \DateTimeZone(drupal_get_user_timezone()); + $user_timezone = new \DateTimeZone(date_default_timezone_get()); if (!empty($this->get('monthly_recurring_date')->end_date)) { return $this->get('monthly_recurring_date')->end_date->setTimezone($user_timezone)->setTime(0, 0, 0); } diff --git a/src/EventCreationService.php b/src/EventCreationService.php index e1bce3d..992583d 100644 --- a/src/EventCreationService.php +++ b/src/EventCreationService.php @@ -174,7 +174,7 @@ class EventCreationService { public function convertFormConfigToArray(FormStateInterface $form_state) { $config = []; - $user_timezone = new \DateTimeZone(drupal_get_user_timezone()); + $user_timezone = new \DateTimeZone(date_default_timezone_get()); $utc_timezone = new \DateTimeZone(DateTimeItemInterface::STORAGE_TIMEZONE); $user_input = $form_state->getUserInput(); @@ -381,7 +381,7 @@ class EventCreationService { $form_data = $this->convertEntityConfigToArray($event); $event_instances = []; - $timezone = new \DateTimeZone(drupal_get_user_timezone()); + $timezone = new \DateTimeZone(date_default_timezone_get()); $utc_timezone = new \DateTimeZone(DateTimeItemInterface::STORAGE_TIMEZONE); if (!empty($form_data['type'])) { diff --git a/src/EventInstanceListBuilder.php b/src/EventInstanceListBuilder.php index 75a47ba..8d75f8f 100644 --- a/src/EventInstanceListBuilder.php +++ b/src/EventInstanceListBuilder.php @@ -122,7 +122,7 @@ class EventInstanceListBuilder extends EntityListBuilder { '#url' => $entity->getEventSeries()->toUrl(), ]; $config = $this->config->get('recurring_events.eventinstance.config'); - $timezone = new \DateTimeZone(drupal_get_user_timezone()); + $timezone = new \DateTimeZone(date_default_timezone_get()); $entity->date->start_date->setTimezone($timezone); $row['date'] = $entity->date->start_date->format($config->get('date_format')); $row['author']['data'] = [ diff --git a/src/EventSeriesListBuilder.php b/src/EventSeriesListBuilder.php index 4aa561f..38ed5f3 100644 --- a/src/EventSeriesListBuilder.php +++ b/src/EventSeriesListBuilder.php @@ -125,7 +125,7 @@ class EventSeriesListBuilder extends EntityListBuilder { $row['type'] = $entity->recur_type->value; $row['instances'] = $entity->getInstanceCount(); $row['starts'] = $this->t('None'); - $timezone = new \DateTimeZone(drupal_get_user_timezone()); + $timezone = new \DateTimeZone(date_default_timezone_get()); if (!empty($entity->getSeriesStart())) { $config = $this->config->get('recurring_events.eventseries.config'); $start_date = $entity->getSeriesStart(); diff --git a/src/Form/EventInstanceDeleteForm.php b/src/Form/EventInstanceDeleteForm.php index 33854d6..9b53f75 100644 --- a/src/Form/EventInstanceDeleteForm.php +++ b/src/Form/EventInstanceDeleteForm.php @@ -75,7 +75,7 @@ class EventInstanceDeleteForm extends ContentEntityDeleteForm { return $this ->t('Are you sure you want to delete the @language translation of the @entity-type %label?', [ '@language' => $entity->language()->getName(), - '@entity-type' => $this->getEntity()->getEntityType()->getLowercaseLabel(), + '@entity-type' => $this->getEntity()->getEntityType()->getSingularLabel(), '%label' => $this->entity->getEventSeries()->title->value, ]); } diff --git a/src/Form/EventSeriesDeleteForm.php b/src/Form/EventSeriesDeleteForm.php index 131250b..7ffe9a2 100644 --- a/src/Form/EventSeriesDeleteForm.php +++ b/src/Form/EventSeriesDeleteForm.php @@ -110,7 +110,7 @@ class EventSeriesDeleteForm extends ContentEntityDeleteForm { ]; $options = []; - $timezone = new \DateTimeZone(drupal_get_user_timezone()); + $timezone = new \DateTimeZone(date_default_timezone_get()); foreach ($instances as $instance) { $date = $instance->date->start_date; $date->setTimezone($timezone); diff --git a/src/Plugin/Field/FieldFormatter/EventInstanceDateFormatter.php b/src/Plugin/Field/FieldFormatter/EventInstanceDateFormatter.php index ace9c0f..0d9d34b 100644 --- a/src/Plugin/Field/FieldFormatter/EventInstanceDateFormatter.php +++ b/src/Plugin/Field/FieldFormatter/EventInstanceDateFormatter.php @@ -98,7 +98,7 @@ class EventInstanceDateFormatter extends EntityReferenceFormatterBase { foreach ($this->getEntitiesToView($items, $langcode) as $delta => $entity) { $date_string = ''; - $user_timezone = new \DateTimeZone(drupal_get_user_timezone()); + $user_timezone = new \DateTimeZone(date_default_timezone_get()); if (!empty($entity->date->start_date) && !empty($entity->date->end_date)) { /** @var \Drupal\Core\Datetime\DrupalDateTime $start_date */ $start_date = $entity->date->start_date; diff --git a/src/Plugin/Field/FieldType/ConsecutiveRecurringDate.php b/src/Plugin/Field/FieldType/ConsecutiveRecurringDate.php index 95bf5ef..9b0cd3f 100644 --- a/src/Plugin/Field/FieldType/ConsecutiveRecurringDate.php +++ b/src/Plugin/Field/FieldType/ConsecutiveRecurringDate.php @@ -137,7 +137,7 @@ class ConsecutiveRecurringDate extends DateRangeItem implements RecurringEventsF public static function convertFormConfigToArray(FormStateInterface $form_state) { $config = []; - $user_timezone = new \DateTimeZone(drupal_get_user_timezone()); + $user_timezone = new \DateTimeZone(date_default_timezone_get()); $utc_timezone = new \DateTimeZone(DateTimeItemInterface::STORAGE_TIMEZONE); $user_input = $form_state->getUserInput(); @@ -342,7 +342,7 @@ class ConsecutiveRecurringDate extends DateRangeItem implements RecurringEventsF $count = 0; $max_time = clone $date; - $user_timezone = new \DateTimeZone(drupal_get_user_timezone()); + $user_timezone = new \DateTimeZone(date_default_timezone_get()); $utc_timezone = new \DateTimeZone(DateTimeItemInterface::STORAGE_TIMEZONE); $time_parts = static::convertTimeTo24hourFormat($form_data['end_time']); diff --git a/src/Plugin/Field/FieldType/DailyRecurringDate.php b/src/Plugin/Field/FieldType/DailyRecurringDate.php index d59c68d..66b6727 100644 --- a/src/Plugin/Field/FieldType/DailyRecurringDate.php +++ b/src/Plugin/Field/FieldType/DailyRecurringDate.php @@ -91,7 +91,7 @@ class DailyRecurringDate extends DateRangeItem implements RecurringEventsFieldTy public static function convertFormConfigToArray(FormStateInterface $form_state) { $config = []; - $user_timezone = new \DateTimeZone(drupal_get_user_timezone()); + $user_timezone = new \DateTimeZone(date_default_timezone_get()); $utc_timezone = new \DateTimeZone(DateTimeItemInterface::STORAGE_TIMEZONE); $user_input = $form_state->getUserInput(); diff --git a/src/Plugin/Field/FieldType/MonthlyRecurringDate.php b/src/Plugin/Field/FieldType/MonthlyRecurringDate.php index 2115444..f65e662 100644 --- a/src/Plugin/Field/FieldType/MonthlyRecurringDate.php +++ b/src/Plugin/Field/FieldType/MonthlyRecurringDate.php @@ -115,7 +115,7 @@ class MonthlyRecurringDate extends WeeklyRecurringDate implements RecurringEvent public static function convertFormConfigToArray(FormStateInterface $form_state) { $config = []; - $user_timezone = new \DateTimeZone(drupal_get_user_timezone()); + $user_timezone = new \DateTimeZone(date_default_timezone_get()); $utc_timezone = new \DateTimeZone(DateTimeItemInterface::STORAGE_TIMEZONE); $user_input = $form_state->getUserInput(); diff --git a/src/Plugin/Field/FieldType/WeeklyRecurringDate.php b/src/Plugin/Field/FieldType/WeeklyRecurringDate.php index 28cc104..455a10c 100644 --- a/src/Plugin/Field/FieldType/WeeklyRecurringDate.php +++ b/src/Plugin/Field/FieldType/WeeklyRecurringDate.php @@ -80,7 +80,7 @@ class WeeklyRecurringDate extends DailyRecurringDate implements RecurringEventsF public static function convertFormConfigToArray(FormStateInterface $form_state) { $config = []; - $user_timezone = new \DateTimeZone(drupal_get_user_timezone()); + $user_timezone = new \DateTimeZone(date_default_timezone_get()); $utc_timezone = new \DateTimeZone(DateTimeItemInterface::STORAGE_TIMEZONE); $user_input = $form_state->getUserInput(); -- GitLab