diff --git a/core/modules/system/lib/Drupal/system/Form/CronForm.php b/core/modules/system/lib/Drupal/system/Form/CronForm.php index a6a803e..2b26b46 100644 --- a/core/modules/system/lib/Drupal/system/Form/CronForm.php +++ b/core/modules/system/lib/Drupal/system/Form/CronForm.php @@ -43,7 +43,7 @@ public function __construct(ConfigFactory $config_factory, ContextInterface $con } /** - * Implements \Drupal\Core\ControllerInterface::create(). + * {@inheritdoc} */ public static function create(ContainerInterface $container) { return new static( @@ -54,14 +54,14 @@ public static function create(ContainerInterface $container) { } /** - * Implements \Drupal\Core\Form\FormInterface::getFormID(). + * {@inheritdoc} */ public function getFormID() { return 'system_cron_settings'; } /** - * Implements \Drupal\Core\Form\FormInterface::buildForm(). + * {@inheritdoc} */ public function buildForm(array $form, array &$form_state) { $config = $this->configFactory->get('system.cron'); @@ -98,7 +98,7 @@ public function buildForm(array $form, array &$form_state) { } /** - * Implements \Drupal\Core\Form\FormInterface::submitForm(). + * {@inheritdoc} */ public function submitForm(array &$form, array &$form_state) { $this->configFactory->get('system.cron') diff --git a/core/modules/system/lib/Drupal/system/Form/FileSystemForm.php b/core/modules/system/lib/Drupal/system/Form/FileSystemForm.php index a34fb4e..96fa21c 100644 --- a/core/modules/system/lib/Drupal/system/Form/FileSystemForm.php +++ b/core/modules/system/lib/Drupal/system/Form/FileSystemForm.php @@ -16,14 +16,14 @@ class FileSystemForm extends SystemConfigFormBase implements ControllerInterface { /** - * Implements \Drupal\Core\Form\FormInterface::getFormID(). + * {@inheritdoc} */ public function getFormID() { return 'system_file_system_settings'; } /** - * Implements \Drupal\Core\Form\FormInterface::buildForm(). + * {@inheritdoc} */ public function buildForm(array $form, array &$form_state) { $config = $this->configFactory->get('system.file'); @@ -73,7 +73,7 @@ public function buildForm(array $form, array &$form_state) { } /** - * Implements \Drupal\Core\Form\FormInterface::submitForm(). + * {@inheritdoc} */ public function submitForm(array &$form, array &$form_state) { $config = $this->configFactory->get('system.file') diff --git a/core/modules/system/lib/Drupal/system/Form/ImageToolkitForm.php b/core/modules/system/lib/Drupal/system/Form/ImageToolkitForm.php new file mode 100644 index 0000000..865bdd0 --- /dev/null +++ b/core/modules/system/lib/Drupal/system/Form/ImageToolkitForm.php @@ -0,0 +1,113 @@ +getAvailableToolkits() as $id => $definition) { + $this->availableToolkits[$id] = $manager->createInstance($id); + } + } + + /** + * {@inheritdoc} + */ + public static function create(ContainerInterface $container) { + return new static( + $container->get('config.factory'), + $container->get('config.context.free'), + $container->get('image.toolkit.manager') + ); + } + + /** + * {@inheritdoc} + */ + public function getFormID() { + return 'system_image_toolkit_settings'; + } + + /** + * {@inheritdoc} + */ + public function buildForm(array $form, array &$form_state) { + $current_toolkit = $this->configFactory->get('system.image')->get('toolkit'); + + $form['image_toolkit'] = array( + '#type' => 'radios', + '#title' => t('Select an image processing toolkit'), + '#default_value' => $current_toolkit, + '#options' => array(), + ); + + // If we have available toolkits, allow the user to select the image toolkit + // to use and load the settings forms. + foreach ($this->availableToolkits as $id => $toolkit) { + $definition = $toolkit->getDefinition(); + $form['image_toolkit']['#options'][$id] = $definition['title']; + $form['image_toolkit_settings'][$id] = array( + '#type' => 'fieldset', + '#title' => t('@toolkit settings', array('@toolkit' => $definition['title'])), + '#collapsible' => TRUE, + '#collapsed' => ($id == $current_toolkit) ? FALSE : TRUE, + '#tree' => TRUE, + ); + $form['image_toolkit_settings'][$id] += $toolkit->settingsForm(); + } + + return parent::buildForm($form, $form_state); + } + + /** + * {@inheritdoc} + */ + public function submitForm(array &$form, array &$form_state) { + $this->configFactory->get('system.image') + ->set('toolkit', $form_state['values']['image_toolkit']) + ->save(); + + // Call the form submit handler for each of the toolkits. + // Get the toolkit settings forms. + foreach ($this->availableToolkits as $id => $toolkit) { + $toolkit->settingsFormSubmit($form, $form_state); + } + + parent::submitForm($form, $form_state); + } + +} diff --git a/core/modules/system/lib/Drupal/system/Form/LoggingForm.php b/core/modules/system/lib/Drupal/system/Form/LoggingForm.php index 4947dfc..77d7b46 100644 --- a/core/modules/system/lib/Drupal/system/Form/LoggingForm.php +++ b/core/modules/system/lib/Drupal/system/Form/LoggingForm.php @@ -16,14 +16,14 @@ class LoggingForm extends SystemConfigFormBase implements ControllerInterface { /** - * Implements \Drupal\Core\Form\FormInterface::getFormID(). + * {@inheritdoc} */ public function getFormID() { return 'system_logging_settings'; } /** - * Implements \Drupal\Core\Form\FormInterface::buildForm(). + * {@inheritdoc} */ public function buildForm(array $form, array &$form_state) { $config = $this->configFactory->get('system.logging'); @@ -44,7 +44,7 @@ public function buildForm(array $form, array &$form_state) { } /** - * Implements \Drupal\Core\Form\FormInterface::submitForm(). + * {@inheritdoc} */ public function submitForm(array &$form, array &$form_state) { $this->configFactory->get('system.logging') diff --git a/core/modules/system/lib/Drupal/system/Form/PerformanceForm.php b/core/modules/system/lib/Drupal/system/Form/PerformanceForm.php index 5dd8f0b..68f2b30 100644 --- a/core/modules/system/lib/Drupal/system/Form/PerformanceForm.php +++ b/core/modules/system/lib/Drupal/system/Form/PerformanceForm.php @@ -16,14 +16,14 @@ class PerformanceForm extends SystemConfigFormBase implements ControllerInterface { /** - * Implements \Drupal\Core\Form\FormInterface::getFormID(). + * {@inheritdoc} */ public function getFormID() { return 'system_performance_settings'; } /** - * Implements \Drupal\Core\Form\FormInterface::buildForm(). + * {@inheritdoc} */ public function buildForm(array $form, array &$form_state) { drupal_add_library('system', 'drupal.system'); @@ -111,7 +111,7 @@ public function buildForm(array $form, array &$form_state) { } /** - * Implements \Drupal\Core\Form\FormInterface::submitForm(). + * {@inheritdoc} */ public function submitForm(array &$form, array &$form_state) { $this->configFactory->get('system.performance') diff --git a/core/modules/system/lib/Drupal/system/Form/RegionalForm.php b/core/modules/system/lib/Drupal/system/Form/RegionalForm.php index 8547753..329db46 100644 --- a/core/modules/system/lib/Drupal/system/Form/RegionalForm.php +++ b/core/modules/system/lib/Drupal/system/Form/RegionalForm.php @@ -16,14 +16,14 @@ class RegionalForm extends SystemConfigFormBase implements ControllerInterface { /** - * Implements \Drupal\Core\Form\FormInterface::getFormID(). + * {@inheritdoc} */ public function getFormID() { return 'system_regional_settings'; } /** - * Implements \Drupal\Core\Form\FormInterface::buildForm(). + * {@inheritdoc} */ public function buildForm(array $form, array &$form_state) { $countries = country_get_list(); @@ -106,7 +106,7 @@ public function buildForm(array $form, array &$form_state) { } /** - * Implements \Drupal\Core\Form\FormInterface::submitForm(). + * {@inheritdoc} */ public function submitForm(array &$form, array &$form_state) { $this->configFactory->get('system.date') diff --git a/core/modules/system/lib/Drupal/system/Form/RssFeedsForm.php b/core/modules/system/lib/Drupal/system/Form/RssFeedsForm.php index 17de11a..08a0702 100644 --- a/core/modules/system/lib/Drupal/system/Form/RssFeedsForm.php +++ b/core/modules/system/lib/Drupal/system/Form/RssFeedsForm.php @@ -16,14 +16,14 @@ class RssFeedsForm extends SystemConfigFormBase implements ControllerInterface { /** - * Implements \Drupal\Core\Form\FormInterface::getFormID(). + * {@inheritdoc} */ public function getFormID() { return 'system_rss_feeds_settings'; } /** - * Implements \Drupal\Core\Form\FormInterface::buildForm(). + * {@inheritdoc} */ public function buildForm(array $form, array &$form_state) { $rss_config = $this->configFactory->get('system.rss'); @@ -56,7 +56,7 @@ public function buildForm(array $form, array &$form_state) { } /** - * Implements \Drupal\Core\Form\FormInterface::submitForm(). + * {@inheritdoc} */ public function submitForm(array &$form, array &$form_state) { $this->configFactory->get('system.rss') diff --git a/core/modules/system/lib/Drupal/system/Form/SiteInformationForm.php b/core/modules/system/lib/Drupal/system/Form/SiteInformationForm.php index 816bc93..8a18dc4 100644 --- a/core/modules/system/lib/Drupal/system/Form/SiteInformationForm.php +++ b/core/modules/system/lib/Drupal/system/Form/SiteInformationForm.php @@ -16,14 +16,14 @@ class SiteInformationForm extends SystemConfigFormBase implements ControllerInterface { /** - * Implements \Drupal\Core\Form\FormInterface::getFormID(). + * {@inheritdoc} */ public function getFormID() { return 'system_site_information_settings'; } /** - * Implements \Drupal\Core\Form\FormInterface::buildForm(). + * {@inheritdoc} */ public function buildForm(array $form, array &$form_state) { $site_config = $this->configFactory->get('system.site'); @@ -93,7 +93,7 @@ public function buildForm(array $form, array &$form_state) { } /** - * Implements \Drupal\Core\Form\FormInterface::validateForm(). + * {@inheritdoc} */ public function validateForm(array &$form, array &$form_state) { // Check for empty front page path. @@ -129,7 +129,7 @@ public function validateForm(array &$form, array &$form_state) { } /** - * Implements \Drupal\Core\Form\FormInterface::submitForm(). + * {@inheritdoc} */ public function submitForm(array &$form, array &$form_state) { $this->configFactory->get('system.site') diff --git a/core/modules/system/lib/Drupal/system/Form/SiteMaintenanceModeForm.php b/core/modules/system/lib/Drupal/system/Form/SiteMaintenanceModeForm.php index dc87a63..daefa17 100644 --- a/core/modules/system/lib/Drupal/system/Form/SiteMaintenanceModeForm.php +++ b/core/modules/system/lib/Drupal/system/Form/SiteMaintenanceModeForm.php @@ -16,14 +16,14 @@ class SiteMaintenanceModeForm extends SystemConfigFormBase implements ControllerInterface { /** - * Implements \Drupal\Core\Form\FormInterface::getFormID(). + * {@inheritdoc} */ public function getFormID() { return 'system_site_maintenance_mode'; } /** - * Implements \Drupal\Core\Form\FormInterface::buildForm(). + * {@inheritdoc} */ public function buildForm(array $form, array &$form_state) { $config = $this->configFactory->get('system.maintenance'); @@ -43,7 +43,7 @@ public function buildForm(array $form, array &$form_state) { } /** - * Implements \Drupal\Core\Form\FormInterface::submitForm(). + * {@inheritdoc} */ public function submitForm(array &$form, array &$form_state) { $this->configFactory->get('system.maintenance') diff --git a/core/modules/system/system.admin.inc b/core/modules/system/system.admin.inc index ec8169a..d344d37 100644 --- a/core/modules/system/system.admin.inc +++ b/core/modules/system/system.admin.inc @@ -1415,66 +1415,6 @@ function system_modules_uninstall_submit($form, &$form_state) { } /** - * Form builder; Configure site image toolkit usage. - * - * @ingroup forms - * @see system_image_toolkit_settings_submit() - */ -function system_image_toolkit_settings($form, &$form_state) { - $manager = Drupal::service('image.toolkit.manager'); - $toolkits_available = $manager->getAvailableToolkits(); - $current_toolkit = config('system.image')->get('toolkit'); - - // If we have available toolkits allow the user to select the image toolkit to - // use and load the settings forms. - $options = array(); - foreach($toolkits_available as $id => $definition) { - $options[$id] = $definition['title']; - } - - $form['image_toolkit'] = array( - '#type' => 'radios', - '#title' => t('Select an image processing toolkit'), - '#default_value' => $current_toolkit, - '#options' => $options, - ); - - // Get the toolkit settings forms. - foreach ($toolkits_available as $id => $definition) { - $toolkit = $manager->createInstance($id); - $form['image_toolkit_settings'][$id] = array( - '#type' => 'fieldset', - '#title' => t('@toolkit settings', array('@toolkit' => $definition['title'])), - '#collapsible' => TRUE, - '#collapsed' => ($id == $current_toolkit) ? FALSE : TRUE, - '#tree' => TRUE, - ); - $form['image_toolkit_settings'][$id] += $toolkit->settingsForm(); - } - - $form = system_config_form($form, $form_state); - - return $form; -} - -/** - * Form submission handler for system_image_toolkit_settings(). - */ -function system_image_toolkit_settings_submit($form, &$form_state) { - config('system.image') - ->set('toolkit', $form_state['values']['image_toolkit']) - ->save(); - - // Call the form submit handler for each of the toolkits. - // Get the toolkit settings forms. - $manager = Drupal::service('image.toolkit.manager'); - foreach ($manager->getAvailableToolkits() as $id => $definition) { - $toolkit = $manager->createInstance($id); - $toolkit->settingsFormSubmit($form, $form_state); - } -} - -/** * Menu callback: displays the site status report. Can also be used as a pure check. * * @param $check diff --git a/core/modules/system/system.module b/core/modules/system/system.module index 014e648..f78c08b 100644 --- a/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -812,10 +812,8 @@ function system_menu() { $items['admin/config/media/image-toolkit'] = array( 'title' => 'Image toolkit', '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'), + 'route_name' => 'system_image_toolkit_settings', 'weight' => 20, - 'file' => 'system.admin.inc', ); // Service settings. diff --git a/core/modules/system/system.routing.yml b/core/modules/system/system.routing.yml index f748f72..b285844 100644 --- a/core/modules/system/system.routing.yml +++ b/core/modules/system/system.routing.yml @@ -60,6 +60,13 @@ system_regional_settings: requirements: _permission: 'administer site configuration' +system_image_toolkit_settings: + pattern: '/admin/config/media/image-toolkit' + defaults: + _form: 'Drupal\system\Form\ImageToolkitForm' + requirements: + _permission: 'administer administration pages' + system_site_maintenance_mode: pattern: '/admin/config/development/maintenance' defaults: