class DateFormatLocalizeResetForm

Builds a form for enabling a module.

Hierarchy

Expanded class hierarchy of DateFormatLocalizeResetForm

1 string reference to 'DateFormatLocalizeResetForm'
system.routing.yml in drupal/core/modules/system/system.routing.yml
drupal/core/modules/system/system.routing.yml

File

drupal/core/modules/system/lib/Drupal/system/Form/DateFormatLocalizeResetForm.php, line 18
Contains \Drupal\system\Form\DateFormatLocalizeResetForm.

Namespace

Drupal\system\Form
View source
class DateFormatLocalizeResetForm extends ConfirmFormBase implements ControllerInterface {

  /**
   * The language to be reset.
   *
   * @var \Drupal\Core\Language\Language;
   */
  protected $language;

  /**
   * The config factory.
   *
   * @var \Drupal\Core\Config\ConfigFactory
   */
  protected $configFactory;

  /**
   * Constructs a DateFormatLocalizeResetForm object.
   */
  public function __construct(ConfigFactory $config_factory) {
    $this->configFactory = $config_factory;
  }

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container) {
    return new static($container
      ->get('config.factory'));
  }

  /**
   * {@inheritdoc}
   */
  public function getFormID() {
    return 'system_date_format_localize_reset_form';
  }

  /**
   * {@inheritdoc}
   */
  protected function getQuestion() {
    return t('Are you sure you want to reset the date formats for %language to the global defaults?', array(
      '%language' => $this->language->name,
    ));
  }

  /**
   * {@inheritdoc}
   */
  protected function getConfirmText() {
    return t('Reset');
  }

  /**
   * {@inheritdoc}
   */
  protected function getCancelPath() {
    return 'admin/config/regional/date-time/locale';
  }

  /**
   * {@inheritdoc}
   */
  protected function getDescription() {
    return t('Resetting will remove all localized date formats for this language. This action cannot be undone.');
  }

  /**
   * {@inheritdoc}
   *
   * @param string $langcode
   *   The language code.
   *
   */
  public function buildForm(array $form, array &$form_state, $langcode = NULL) {
    $this->language = language_load($langcode);
    return parent::buildForm($form, $form_state);
  }

  /**
   * {@inheritdoc}
   */
  public function submitForm(array &$form, array &$form_state) {
    $this->configFactory
      ->get('locale.config.' . $this->language->langcode . '.system.date')
      ->delete();
    $form_state['redirect'] = 'admin/config/regional/date-time/locale';
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ConfirmFormBase::getCancelText protected function Returns a caption for the link which cancels the action. 2
ConfirmFormBase::getFormName protected function Returns the internal name used to refer to the confirmation item.
ConfirmFormBase::validateForm public function Implements \Drupal\Core\Form\FormInterface::validateForm(). Overrides FormInterface::validateForm 1
DateFormatLocalizeResetForm::$configFactory protected property The config factory.
DateFormatLocalizeResetForm::$language protected property The language to be reset.
DateFormatLocalizeResetForm::buildForm public function Overrides ConfirmFormBase::buildForm
DateFormatLocalizeResetForm::create public static function Instantiates a new instance of this controller. Overrides ControllerInterface::create
DateFormatLocalizeResetForm::getCancelPath protected function Returns the page to go to if the user cancels the action. Overrides ConfirmFormBase::getCancelPath
DateFormatLocalizeResetForm::getConfirmText protected function Returns a caption for the button that confirms the action. Overrides ConfirmFormBase::getConfirmText
DateFormatLocalizeResetForm::getDescription protected function Returns additional text to display as a description. Overrides ConfirmFormBase::getDescription
DateFormatLocalizeResetForm::getFormID public function Returns a unique string identifying the form. Overrides FormInterface::getFormID
DateFormatLocalizeResetForm::getQuestion protected function Returns the question to ask the user. Overrides ConfirmFormBase::getQuestion
DateFormatLocalizeResetForm::submitForm public function Form submission handler. Overrides FormInterface::submitForm
DateFormatLocalizeResetForm::__construct public function Constructs a DateFormatLocalizeResetForm object.