commit 739cfb8a86626c885c484466e2107d5b99f214e6 Author: Lucas D Hedding Date: Fri Apr 26 07:00:47 2013 -0500 Issue #1925660 by ACF, tim.plunkett, mtift, Cottser, heddn: Convert system's system_config_form() to SystemConfigFormBase. diff --git a/core/modules/system/lib/Drupal/system/Form/CronForm.php b/core/modules/system/lib/Drupal/system/Form/CronForm.php index 119d8a9..a6a803e 100644 --- a/core/modules/system/lib/Drupal/system/Form/CronForm.php +++ b/core/modules/system/lib/Drupal/system/Form/CronForm.php @@ -9,14 +9,16 @@ use Drupal\Core\Config\ConfigFactory; use Drupal\Core\Config\Context\ContextInterface; +use Drupal\Core\ControllerInterface; use Drupal\Core\KeyValueStore\KeyValueFactory; +use Drupal\system\SystemConfigFormBase; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\RedirectResponse; /** * Configure cron settings for this site. */ -class CronForm extends SystemFormBase { +class CronForm extends SystemConfigFormBase implements ControllerInterface { /** * Stores the state storage service. @@ -36,8 +38,7 @@ class CronForm extends SystemFormBase { * The state key value store. */ public function __construct(ConfigFactory $config_factory, ContextInterface $context, KeyValueFactory $key_value_factory) { - $this->configFactory = $config_factory; - $this->configFactory->enterContext($context); + parent::__construct($config_factory, $context); $this->state = $key_value_factory->get('state'); } diff --git a/core/modules/system/lib/Drupal/system/Form/FileSystemForm.php b/core/modules/system/lib/Drupal/system/Form/FileSystemForm.php index 1e159ba..a34fb4e 100644 --- a/core/modules/system/lib/Drupal/system/Form/FileSystemForm.php +++ b/core/modules/system/lib/Drupal/system/Form/FileSystemForm.php @@ -7,10 +7,13 @@ namespace Drupal\system\Form; +use Drupal\Core\ControllerInterface; +use Drupal\system\SystemConfigFormBase; + /** * Configure file system settings for this site. */ -class FileSystemForm extends SystemFormBase { +class FileSystemForm extends SystemConfigFormBase implements ControllerInterface { /** * Implements \Drupal\Core\Form\FormInterface::getFormID(). diff --git a/core/modules/system/lib/Drupal/system/Form/LoggingForm.php b/core/modules/system/lib/Drupal/system/Form/LoggingForm.php index 1f38ae8..4947dfc 100644 --- a/core/modules/system/lib/Drupal/system/Form/LoggingForm.php +++ b/core/modules/system/lib/Drupal/system/Form/LoggingForm.php @@ -7,10 +7,13 @@ namespace Drupal\system\Form; +use Drupal\Core\ControllerInterface; +use Drupal\system\SystemConfigFormBase; + /** * Configure logging settings for this site. */ -class LoggingForm extends SystemFormBase { +class LoggingForm extends SystemConfigFormBase implements ControllerInterface { /** * Implements \Drupal\Core\Form\FormInterface::getFormID(). diff --git a/core/modules/system/lib/Drupal/system/Form/PerformanceForm.php b/core/modules/system/lib/Drupal/system/Form/PerformanceForm.php index 288d2af..5dd8f0b 100644 --- a/core/modules/system/lib/Drupal/system/Form/PerformanceForm.php +++ b/core/modules/system/lib/Drupal/system/Form/PerformanceForm.php @@ -7,10 +7,13 @@ namespace Drupal\system\Form; +use Drupal\Core\ControllerInterface; +use Drupal\system\SystemConfigFormBase; + /** * Configure performance settings for this site. */ -class PerformanceForm extends SystemFormBase { +class PerformanceForm extends SystemConfigFormBase implements ControllerInterface { /** * Implements \Drupal\Core\Form\FormInterface::getFormID(). @@ -111,13 +114,13 @@ public function buildForm(array $form, array &$form_state) { * Implements \Drupal\Core\Form\FormInterface::submitForm(). */ public function submitForm(array &$form, array &$form_state) { - $config = $this->configFactory->get('system.performance'); - $config->set('cache.page.use_internal', $form_state['values']['cache']); - $config->set('cache.page.max_age', $form_state['values']['page_cache_maximum_age']); - $config->set('response.gzip', $form_state['values']['page_compression']); - $config->set('css.preprocess', $form_state['values']['preprocess_css']); - $config->set('js.preprocess', $form_state['values']['preprocess_js']); - $config->save(); + $this->configFactory->get('system.performance') + ->set('cache.page.use_internal', $form_state['values']['cache']) + ->set('cache.page.max_age', $form_state['values']['page_cache_maximum_age']) + ->set('response.gzip', $form_state['values']['page_compression']) + ->set('css.preprocess', $form_state['values']['preprocess_css']) + ->set('js.preprocess', $form_state['values']['preprocess_js']) + ->save(); parent::submitForm($form, $form_state); } @@ -136,7 +139,7 @@ public function submitCacheClear(array &$form, array &$form_state) { * @ingroup forms */ public function systemClearPageCacheSubmit(array $form, array &$form_state) { - cache('page')->deleteAll(); + \Drupal::cache('page')->deleteAll(); } } diff --git a/core/modules/system/lib/Drupal/system/Form/RegionalForm.php b/core/modules/system/lib/Drupal/system/Form/RegionalForm.php index b202975..8547753 100644 --- a/core/modules/system/lib/Drupal/system/Form/RegionalForm.php +++ b/core/modules/system/lib/Drupal/system/Form/RegionalForm.php @@ -7,10 +7,13 @@ namespace Drupal\system\Form; +use Drupal\Core\ControllerInterface; +use Drupal\system\SystemConfigFormBase; + /** * Configure regional settings for this site. */ -class RegionalForm extends SystemFormBase { +class RegionalForm extends SystemConfigFormBase implements ControllerInterface { /** * Implements \Drupal\Core\Form\FormInterface::getFormID(). diff --git a/core/modules/system/lib/Drupal/system/Form/RssFeedsForm.php b/core/modules/system/lib/Drupal/system/Form/RssFeedsForm.php index cd4a35b..17de11a 100644 --- a/core/modules/system/lib/Drupal/system/Form/RssFeedsForm.php +++ b/core/modules/system/lib/Drupal/system/Form/RssFeedsForm.php @@ -7,10 +7,13 @@ namespace Drupal\system\Form; +use Drupal\Core\ControllerInterface; +use Drupal\system\SystemConfigFormBase; + /** * Configure RSS settings for this site. */ -class RssFeedsForm extends SystemFormBase { +class RssFeedsForm extends SystemConfigFormBase implements ControllerInterface { /** * Implements \Drupal\Core\Form\FormInterface::getFormID(). diff --git a/core/modules/system/lib/Drupal/system/Form/SiteInformationForm.php b/core/modules/system/lib/Drupal/system/Form/SiteInformationForm.php index 1f32a85..816bc93 100644 --- a/core/modules/system/lib/Drupal/system/Form/SiteInformationForm.php +++ b/core/modules/system/lib/Drupal/system/Form/SiteInformationForm.php @@ -7,10 +7,13 @@ namespace Drupal\system\Form; +use Drupal\Core\ControllerInterface; +use Drupal\system\SystemConfigFormBase; + /** * Configure site information settings for this site. */ -class SiteInformationForm extends SystemFormBase { +class SiteInformationForm extends SystemConfigFormBase implements ControllerInterface { /** * Implements \Drupal\Core\Form\FormInterface::getFormID(). diff --git a/core/modules/system/lib/Drupal/system/Form/SiteMaintenanceModeForm.php b/core/modules/system/lib/Drupal/system/Form/SiteMaintenanceModeForm.php index 1827124..dc87a63 100644 --- a/core/modules/system/lib/Drupal/system/Form/SiteMaintenanceModeForm.php +++ b/core/modules/system/lib/Drupal/system/Form/SiteMaintenanceModeForm.php @@ -7,10 +7,13 @@ namespace Drupal\system\Form; +use Drupal\Core\ControllerInterface; +use Drupal\system\SystemConfigFormBase; + /** * Configure maintenance settings for this site. */ -class SiteMaintenanceModeForm extends SystemFormBase { +class SiteMaintenanceModeForm extends SystemConfigFormBase implements ControllerInterface { /** * Implements \Drupal\Core\Form\FormInterface::getFormID(). diff --git a/core/modules/system/lib/Drupal/system/Form/SystemFormBase.php b/core/modules/system/lib/Drupal/system/Form/SystemFormBase.php deleted file mode 100644 index ca40ea2..0000000 --- a/core/modules/system/lib/Drupal/system/Form/SystemFormBase.php +++ /dev/null @@ -1,43 +0,0 @@ -configFactory = $config_factory; - $this->configFactory->enterContext($context); - } - - /** - * Implements \Drupal\Core\ControllerInterface::create(). - */ - public static function create(ContainerInterface $container) { - return new static( - $container->get('config.factory'), - $container->get('config.context.free') - ); - } - -} diff --git a/core/modules/system/system.module b/core/modules/system/system.module index d042e21..4f324ca 100644 --- a/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -807,7 +807,6 @@ function system_menu() { 'title' => 'File system', 'description' => 'Tell Drupal where to store uploaded files and how they are accessed.', 'route_name' => 'system_file_system_settings', - 'access arguments' => array('administer site configuration'), 'weight' => -10, ); $items['admin/config/media/image-toolkit'] = array( @@ -815,7 +814,6 @@ function system_menu() { 'description' => 'Choose which image toolkit to use if you have installed optional toolkits.', 'page callback' => 'drupal_get_form', 'page arguments' => array('system_image_toolkit_settings'), - 'access arguments' => array('administer site configuration'), 'weight' => 20, 'file' => 'system.admin.inc', ); @@ -834,7 +832,6 @@ function system_menu() { 'title' => 'RSS publishing', 'description' => 'Configure the site description, the number of items per feed and whether feeds should be titles/teasers/full-text.', 'route_name' => 'system_rss_feeds_settings', - 'access arguments' => array('administer site configuration'), ); // Development settings. @@ -851,21 +848,18 @@ function system_menu() { 'title' => 'Maintenance mode', 'description' => 'Take the site offline for maintenance or bring it back online.', 'route_name' => 'system_site_maintenance_mode', - 'access arguments' => array('administer site configuration'), 'weight' => -10, ); $items['admin/config/development/performance'] = array( 'title' => 'Performance', 'description' => 'Enable or disable page caching for anonymous users and set CSS and JS bandwidth optimization options.', 'route_name' => 'system_performance_settings', - 'access arguments' => array('administer site configuration'), 'weight' => -20, ); $items['admin/config/development/logging'] = array( 'title' => 'Logging and errors', 'description' => "Settings for logging and alerts modules. Various modules can route Drupal's system events to different destinations, such as syslog, database, email, etc.", 'route_name' => 'system_logging_settings', - 'access arguments' => array('administer site configuration'), 'weight' => -15, ); @@ -883,14 +877,12 @@ function system_menu() { 'title' => 'Regional settings', 'description' => "Settings for the site's default time zone and country.", 'route_name' => 'system_regional_settings', - 'access arguments' => array('administer site configuration'), 'weight' => -20, ); $items['admin/config/regional/date-time'] = array( 'title' => 'Formats', 'description' => 'Configure display format strings for date and time.', 'page callback' => 'system_date_time_formats', - 'access arguments' => array('administer site configuration'), 'weight' => -9, 'file' => 'system.admin.inc', ); @@ -900,7 +892,6 @@ function system_menu() { 'type' => MENU_LOCAL_ACTION, 'page callback' => 'drupal_get_form', 'page arguments' => array('system_configure_date_formats_form'), - 'access arguments' => array('administer site configuration'), 'weight' => -10, 'file' => 'system.admin.inc', ); @@ -909,7 +900,6 @@ function system_menu() { 'description' => 'Allow users to edit a configured date format.', 'page callback' => 'drupal_get_form', 'page arguments' => array('system_configure_date_formats_form', 5), - 'access arguments' => array('administer site configuration'), 'file' => 'system.admin.inc', ); $items['admin/config/regional/date-time/formats/%system_date_format/delete'] = array( @@ -917,13 +907,11 @@ function system_menu() { 'description' => 'Allow users to delete a configured date format.', 'page callback' => 'drupal_get_form', 'page arguments' => array('system_date_delete_format_form', 5), - 'access arguments' => array('administer site configuration'), 'file' => 'system.admin.inc', ); $items['admin/config/regional/date-time/formats/lookup'] = array( 'title' => 'Date and time lookup', 'page callback' => 'system_date_time_lookup', - 'access arguments' => array('administer site configuration'), 'type' => MENU_CALLBACK, 'file' => 'system.admin.inc', ); @@ -953,14 +941,12 @@ function system_menu() { 'title' => 'Site information', 'description' => 'Change site name, e-mail address, slogan, default front page, and number of posts per page, error pages.', 'route_name' => 'system_site_information_settings', - 'access arguments' => array('administer site configuration'), 'weight' => -20, ); $items['admin/config/system/cron'] = array( 'title' => 'Cron', 'description' => 'Manage automatic site maintenance tasks.', 'route_name' => 'system_cron_settings', - 'access arguments' => array('administer site configuration'), 'weight' => 20, ); // Additional categories @@ -1007,20 +993,17 @@ function system_menu() { 'description' => "Get a status report about your site's operation and any detected problems.", 'page callback' => 'system_status', 'weight' => -60, - 'access arguments' => array('administer site configuration'), 'file' => 'system.admin.inc', ); $items['admin/reports/status/run-cron'] = array( 'title' => 'Run cron', 'page callback' => 'system_run_cron', - 'access arguments' => array('administer site configuration'), 'type' => MENU_CALLBACK, 'file' => 'system.admin.inc', ); $items['admin/reports/status/php'] = array( 'title' => 'PHP', 'page callback' => 'system_php', - 'access arguments' => array('administer site configuration'), 'type' => MENU_CALLBACK, 'file' => 'system.admin.inc', ); @@ -1040,7 +1023,6 @@ function system_menu() { 'title' => 'Localize', 'description' => 'Configure date formats for each locale', 'page callback' => 'system_date_format_language_overview_page', - 'access arguments' => array('administer site configuration'), 'type' => MENU_LOCAL_TASK, 'weight' => -8, 'file' => 'system.admin.inc', @@ -1050,7 +1032,6 @@ function system_menu() { 'description' => 'Configure date formats for each locale', 'page callback' => 'drupal_get_form', 'page arguments' => array('system_date_format_localize_form', 5), - 'access arguments' => array('administer site configuration'), 'file' => 'system.admin.inc', ); $items['admin/config/regional/date-time/locale/%/reset'] = array( @@ -1058,7 +1039,6 @@ function system_menu() { 'description' => 'Reset localized date formats to global defaults', 'page callback' => 'drupal_get_form', 'page arguments' => array('system_date_format_localize_reset_form', 5), - 'access arguments' => array('administer site configuration'), 'file' => 'system.admin.inc', ); }