Unverified Commit 6bce3bb2 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3112704 by berdir, longwave: Move user_user_presave() to User entity class

parent e3ccb201
Loading
Loading
Loading
Loading
Loading
+5 −0
Changes for core/modules/user/src/Entity/User.php: 5 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -119,6 +119,11 @@ public function preSave(EntityStorageInterface $storage) {
        \Drupal::service('user.data')->set('user', $this->id(), substr($key, 5), $this->{$key});
      }
    }

    $config = \Drupal::config('system.date');
    if ($config->get('timezone.user.configurable') && !$this->getTimeZone() && !$config->get('timezone.user.default')) {
      $this->set('timezone', $config->get('timezone.default'));
    }
  }

  /**
+0 −14
Changes for core/modules/user/src/Hook/UserHooks.php: 0 added lines, 14 removed lines.
Original line number Diff line number Diff line
@@ -134,20 +134,6 @@ public function entityExtraFieldInfo(): array {
    return $fields;
  }

  /**
   * Implements hook_ENTITY_TYPE_presave() for user entities.
   *
   * @todo https://www.drupal.org/project/drupal/issues/3112704 Move to
   *   \Drupal\user\Entity\User::preSave().
   */
  #[Hook('user_presave')]
  public function userPresave(UserInterface $account): void {
    $config = \Drupal::config('system.date');
    if ($config->get('timezone.user.configurable') && !$account->getTimeZone() && !$config->get('timezone.user.default')) {
      $account->timezone = $config->get('timezone.default');
    }
  }

  /**
   * Implements hook_ENTITY_TYPE_view() for user entities.
   */