Commit 3cc8a612 authored by catch's avatar catch
Browse files

Issue #3015752 by alexpott, bnjmnm: Properly deprecate USERNAME_MAX_LENGTH and...

Issue #3015752 by alexpott, bnjmnm: Properly deprecate USERNAME_MAX_LENGTH and USER_REGISTER_* constants
parent 140e97ef
Loading
Loading
Loading
Loading
+2 −1
Changes for core/lib/Drupal/Core/Installer/Form/SiteConfigureForm.php: 2 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -9,6 +9,7 @@
use Drupal\Core\Site\Settings;
use Drupal\Core\State\StateInterface;
use Drupal\user\UserStorageInterface;
use Drupal\user\UserInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;

/**
@@ -178,7 +179,7 @@ public function buildForm(array $form, FormStateInterface $form_state) {
    $form['admin_account']['account']['name'] = [
      '#type' => 'textfield',
      '#title' => $this->t('Username'),
      '#maxlength' => USERNAME_MAX_LENGTH,
      '#maxlength' => UserInterface::USERNAME_MAX_LENGTH,
      '#description' => $this->t("Several special characters are allowed, including space, period (.), hyphen (-), apostrophe ('), underscore (_), and the @ sign."),
      '#required' => TRUE,
      '#attributes' => ['class' => ['username']],
+2 −1
Changes for core/modules/comment/src/CommentManager.php: 2 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
use Drupal\field\Entity\FieldStorageConfig;
use Drupal\field\Entity\FieldConfig;
use Drupal\user\RoleInterface;
use Drupal\user\UserInterface;

/**
 * Comment manager contains common functions to manage comment fields.
@@ -174,7 +175,7 @@ public function forbiddenMessage(EntityInterface $entity, $field_name) {
        $destination = ['destination' => $entity->toUrl('canonical', ['fragment' => 'comment-form'])->toString()];
      }

      if ($this->userConfig->get('register') != USER_REGISTER_ADMINISTRATORS_ONLY) {
      if ($this->userConfig->get('register') != UserInterface::REGISTER_ADMINISTRATORS_ONLY) {
        // Users can register themselves.
        return $this->t('<a href=":login">Log in</a> or <a href=":register">register</a> to post comments', [
          ':login' => Url::fromRoute('user.login', [], ['query' => $destination])->toString(),
+2 −1
Changes for core/modules/user/src/Access/RegisterAccessCheck.php: 2 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@
use Drupal\Core\Access\AccessResult;
use Drupal\Core\Routing\Access\AccessInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\user\UserInterface;

/**
 * Access check for user registration routes.
@@ -22,7 +23,7 @@ class RegisterAccessCheck implements AccessInterface {
   */
  public function access(AccountInterface $account) {
    $user_settings = \Drupal::config('user.settings');
    return AccessResult::allowedIf($account->isAnonymous() && $user_settings->get('register') != USER_REGISTER_ADMINISTRATORS_ONLY)->cacheUntilConfigurationChanges($user_settings);
    return AccessResult::allowedIf($account->isAnonymous() && $user_settings->get('register') != UserInterface::REGISTER_ADMINISTRATORS_ONLY)->cacheUntilConfigurationChanges($user_settings);
  }

}
+2 −2
Changes for core/modules/user/src/AccountForm.php: 2 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -104,7 +104,7 @@ public function form(array $form, FormStateInterface $form_state) {
    $form['account']['name'] = [
      '#type' => 'textfield',
      '#title' => $this->t('Username'),
      '#maxlength' => USERNAME_MAX_LENGTH,
      '#maxlength' => UserInterface::USERNAME_MAX_LENGTH,
      '#description' => $this->t("Several special characters are allowed, including space, period (.), hyphen (-), apostrophe ('), underscore (_), and the @ sign."),
      '#required' => TRUE,
      '#attributes' => [
@@ -184,7 +184,7 @@ public function form(array $form, FormStateInterface $form_state) {
      $status = $account->get('status')->value;
    }
    else {
      $status = $config->get('register') == USER_REGISTER_VISITORS ? 1 : 0;
      $status = $config->get('register') == UserInterface::REGISTER_VISITORS ? 1 : 0;
    }

    $form['account']['status'] = [
+7 −7
Changes for core/modules/user/src/AccountSettingsForm.php: 7 added lines, 7 removed lines.
Original line number Diff line number Diff line
@@ -151,9 +151,9 @@ public function buildForm(array $form, FormStateInterface $form_state) {
      '#title' => $this->t('Who can register accounts?'),
      '#default_value' => $config->get('register'),
      '#options' => [
        USER_REGISTER_ADMINISTRATORS_ONLY => $this->t('Administrators only'),
        USER_REGISTER_VISITORS => $this->t('Visitors'),
        USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL => $this->t('Visitors, but administrator approval is required'),
        UserInterface::REGISTER_ADMINISTRATORS_ONLY => $this->t('Administrators only'),
        UserInterface::REGISTER_VISITORS => $this->t('Visitors'),
        UserInterface::REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL => $this->t('Visitors, but administrator approval is required'),
      ],
    ];
    $form['registration_cancellation']['user_email_verification'] = [
@@ -203,7 +203,7 @@ public function buildForm(array $form, FormStateInterface $form_state) {
    $form['email_admin_created'] = [
      '#type' => 'details',
      '#title' => $this->t('Welcome (new user created by administrator)'),
      '#open' => $config->get('register') == USER_REGISTER_ADMINISTRATORS_ONLY,
      '#open' => $config->get('register') == UserInterface::REGISTER_ADMINISTRATORS_ONLY,
      '#description' => $this->t('Edit the welcome email messages sent to new member accounts created by an administrator.') . ' ' . $email_token_help,
      '#group' => 'email',
    ];
@@ -223,7 +223,7 @@ public function buildForm(array $form, FormStateInterface $form_state) {
    $form['email_pending_approval'] = [
      '#type' => 'details',
      '#title' => $this->t('Welcome (awaiting approval)'),
      '#open' => $config->get('register') == USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL,
      '#open' => $config->get('register') == UserInterface::REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL,
      '#description' => $this->t('Edit the welcome email messages sent to new members upon registering, when administrative approval is required.') . ' ' . $email_token_help,
      '#group' => 'email',
    ];
@@ -243,7 +243,7 @@ public function buildForm(array $form, FormStateInterface $form_state) {
    $form['email_pending_approval_admin'] = [
      '#type' => 'details',
      '#title' => $this->t('Admin (user awaiting approval)'),
      '#open' => $config->get('register') == USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL,
      '#open' => $config->get('register') == UserInterface::REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL,
      '#description' => $this->t('Edit the email notifying the site administrator that there are new members awaiting administrative approval.') . ' ' . $email_token_help,
      '#group' => 'email',
    ];
@@ -263,7 +263,7 @@ public function buildForm(array $form, FormStateInterface $form_state) {
    $form['email_no_approval_required'] = [
      '#type' => 'details',
      '#title' => $this->t('Welcome (no approval required)'),
      '#open' => $config->get('register') == USER_REGISTER_VISITORS,
      '#open' => $config->get('register') == UserInterface::REGISTER_VISITORS,
      '#description' => $this->t('Edit the welcome email messages sent to new members upon registering, when no administrator approval is required.') . ' ' . $email_token_help,
      '#group' => 'email',
    ];
Loading