diff --git a/core/modules/system/lib/Drupal/system/Form/DateFormatDeleteForm.php b/core/modules/system/lib/Drupal/system/Form/DateFormatDeleteForm.php index ab107f5..cf20038 100644 --- a/core/modules/system/lib/Drupal/system/Form/DateFormatDeleteForm.php +++ b/core/modules/system/lib/Drupal/system/Form/DateFormatDeleteForm.php @@ -8,11 +8,14 @@ namespace Drupal\system\Form; use Drupal\Core\Form\ConfirmFormBase; +use Drupal\Core\ControllerInterface; +use Drupal\Core\Config\ConfigFactory; +use Symfony\Component\DependencyInjection\ContainerInterface; /** * Builds a form to delete a date format. */ -class DateFormatDeleteForm extends ConfirmFormBase { +class DateFormatDeleteForm extends ConfirmFormBase implements ControllerInterface { /** * The date format data to be deleted. @@ -22,11 +25,41 @@ class DateFormatDeleteForm extends ConfirmFormBase { protected $format; /** - * The id of the date format to be deleted. + * The ID of the date format to be deleted. * * @var string */ - protected $formatId; + protected $formatID; + + /** + * The config factory. + * + * @var \Drupal\Core\Config\ConfigFactory + */ + protected $configFactory; + + /** + * Constructs a DateFormatDeleteForm 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_delete_format_form'; + } /** * {@inheritdoc} @@ -34,7 +67,7 @@ class DateFormatDeleteForm extends ConfirmFormBase { protected function getQuestion() { return t('Are you sure you want to remove the format %name : %format?', array( '%name' => $this->format['name'], - '%format' => format_date(REQUEST_TIME, $this->formatId)) + '%format' => format_date(REQUEST_TIME, $this->formatID)) ); } @@ -55,17 +88,10 @@ protected function getCancelPath() { /** * {@inheritdoc} */ - public function getFormID() { - return 'system_date_delete_format_form'; - } - - /** - * {@inheritdoc} - */ public function buildForm(array $form, array &$form_state, $format_id = NULL) { - // We don't get the format id in the returned format array. - $this->formatId = $format_id; - $this->format = system_get_date_formats($format_id); + // We don't get the format ID in the returned format array. + $this->formatID = $format_id; + $this->format = $this->configFactory->get('system.date')->get("formats.$format_id"); return parent::buildForm($form, $form_state); } @@ -74,7 +100,7 @@ public function buildForm(array $form, array &$form_state, $format_id = NULL) { * {@inheritdoc} */ public function submitForm(array &$form, array &$form_state) { - system_date_format_delete($this->formatId); + system_date_format_delete($this->formatID); drupal_set_message(t('Removed date format %format.', array('%format' => $this->format['name']))); $form_state['redirect'] = 'admin/config/regional/date-time/formats'; diff --git a/core/modules/system/lib/Drupal/system/Form/DateFormatLocalizeResetForm.php b/core/modules/system/lib/Drupal/system/Form/DateFormatLocalizeResetForm.php index 47fa2a8..067f9f5 100644 --- a/core/modules/system/lib/Drupal/system/Form/DateFormatLocalizeResetForm.php +++ b/core/modules/system/lib/Drupal/system/Form/DateFormatLocalizeResetForm.php @@ -8,11 +8,14 @@ namespace Drupal\system\Form; use Drupal\Core\Form\ConfirmFormBase; +use Drupal\Core\ControllerInterface; +use Drupal\Core\Config\ConfigFactory; +use Symfony\Component\DependencyInjection\ContainerInterface; /** * Builds a form for enabling a module. */ -class DateFormatLocalizeResetForm extends ConfirmFormBase { +class DateFormatLocalizeResetForm extends ConfirmFormBase implements ControllerInterface { /** * The language to be reset. @@ -22,11 +25,34 @@ class DateFormatLocalizeResetForm extends ConfirmFormBase { protected $language; /** - * The id of the date format to be deleted. + * The config factory. * - * @var string + * @var \Drupal\Core\Config\ConfigFactory */ - protected $formatId; + 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} @@ -61,13 +87,6 @@ protected function getDescription() { /** * {@inheritdoc} */ - public function getFormID() { - return 'system_date_format_localize_reset_form'; - } - - /** - * {@inheritdoc} - */ public function buildForm(array $form, array &$form_state, $langcode = NULL) { $this->language = language_load($langcode); @@ -78,8 +97,7 @@ public function buildForm(array $form, array &$form_state, $langcode = NULL) { * {@inheritdoc} */ public function submitForm(array &$form, array &$form_state) { - - config('locale.config.' . $this->language->langcode . '.system.date')->delete(); + $this->configFactory->get('locale.config.' . $this->language->langcode . '.system.date')->delete(); $form_state['redirect'] = 'admin/config/regional/date-time/locale'; }