Verified Commit 68365af0 authored by Théodore Biadala's avatar Théodore Biadala
Browse files

Issue #3439439 by nicxvan, dww, longwave, andypost, quietone: Remove country...

Issue #3439439 by nicxvan, dww, longwave, andypost, quietone: Remove country setting from the installer
parent 86b89313
Loading
Loading
Loading
Loading
Loading
+18 −28
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@
namespace Drupal\Core\Installer\Form;

use Drupal\Core\Datetime\TimeZoneFormHelper;
use Drupal\Core\DependencyInjection\DeprecatedServicePropertyTrait;
use Drupal\Core\Extension\ModuleInstallerInterface;
use Drupal\Core\Form\ConfigFormBase;
use Drupal\Core\Form\FormStateInterface;
@@ -20,6 +21,17 @@
 */
class SiteConfigureForm extends ConfigFormBase {

  use DeprecatedServicePropertyTrait;

  /**
   * Defines deprecated injected properties.
   *
   * @var array
   */
  protected array $deprecatedProperties = [
    'countryManager' => 'country_manager',
  ];

  /**
   * The site path.
   *
@@ -41,13 +53,6 @@ class SiteConfigureForm extends ConfigFormBase {
   */
  protected $moduleInstaller;

  /**
   * The country manager.
   *
   * @var \Drupal\Core\Locale\CountryManagerInterface
   */
  protected $countryManager;

  /**
   * The app root.
   *
@@ -66,9 +71,7 @@ class SiteConfigureForm extends ConfigFormBase {
   *   The user storage.
   * @param \Drupal\Core\Extension\ModuleInstallerInterface $module_installer
   *   The module installer.
   * @param \Drupal\Core\Locale\CountryManagerInterface $country_manager
   *   The country manager.
   * @param \Drupal\user\UserNameValidator|null $userNameValidator
   * @param \Drupal\Core\Locale\CountryManagerInterface|\Drupal\user\UserNameValidator $userNameValidator
   *   The user validator.
   */
  public function __construct(
@@ -76,18 +79,17 @@ public function __construct(
    $site_path,
    UserStorageInterface $user_storage,
    ModuleInstallerInterface $module_installer,
    CountryManagerInterface $country_manager,
    protected ?UserNameValidator $userNameValidator = NULL,
    protected CountryManagerInterface|UserNameValidator $userNameValidator,
  ) {
    $this->root = $root;
    $this->sitePath = $site_path;
    $this->userStorage = $user_storage;
    $this->moduleInstaller = $module_installer;
    $this->countryManager = $country_manager;
    if (!$userNameValidator) {
      @\trigger_error('Calling ' . __METHOD__ . ' without the $userNameValidator argument is deprecated in drupal:10.3.0 and will be required in drupal:11.0.0. See https://www.drupal.org/node/3431205', E_USER_DEPRECATED);
      $this->userNameValidator = \Drupal::service('user.name_validator');
    if ($userNameValidator instanceof CountryManagerInterface) {
      @trigger_error('Calling ' . __METHOD__ . '() with the $userNameValidator argument as CountryManagerInterface is deprecated in drupal:10.3.0 and must be UserNameValidator in drupal:11.0.0. See https://www.drupal.org/node/3431205', E_USER_DEPRECATED);
      $userNameValidator = \Drupal::service('user.name_validator');
    }
    $this->userNameValidator = $userNameValidator;
  }

  /**
@@ -99,7 +101,6 @@ public static function create(ContainerInterface $container) {
      $container->getParameter('site.path'),
      $container->get('entity_type.manager')->getStorage('user'),
      $container->get('module_installer'),
      $container->get('country_manager'),
      $container->get('user.name_validator'),
    );
  }
@@ -205,16 +206,6 @@ public function buildForm(array $form, FormStateInterface $form_state) {
      '#title' => $this->t('Regional settings'),
      '#access' => empty($install_state['config_install_path']),
    ];
    $countries = $this->countryManager->getList();
    $form['regional_settings']['site_default_country'] = [
      '#type' => 'select',
      '#title' => $this->t('Default country'),
      '#empty_value' => '',
      '#default_value' => $this->config('system.date')->get('country.default'),
      '#options' => $countries,
      '#weight' => 0,
      '#access' => empty($install_state['config_install_path']),
    ];
    // Use the default site timezone if one is already configured, or fall back
    // to the system timezone if set (and avoid throwing a warning in
    // PHP >=5.4).
@@ -288,7 +279,6 @@ public function submitForm(array &$form, FormStateInterface $form_state) {

      $this->config('system.date')
        ->set('timezone.default', (string) $form_state->getValue('date_default_timezone'))
        ->set('country.default', (string) $form_state->getValue('site_default_country'))
        ->save(TRUE);
    }