diff --git a/core/modules/system/src/Controller/PerformanceController.php b/core/modules/system/src/Controller/PerformanceController.php new file mode 100644 index 0000000000000000000000000000000000000000..de0cb03bb9ffdd346e3d76fac1cd2ca3eabc55df --- /dev/null +++ b/core/modules/system/src/Controller/PerformanceController.php @@ -0,0 +1,28 @@ +<?php + +namespace Drupal\system\Controller; + +use Drupal\Core\Controller\ControllerBase; +use Drupal\system\Form\ClearCacheForm; +use Drupal\system\Form\PerformanceForm; + +/** + * Controller for performance admin. + */ +class PerformanceController extends ControllerBase { + + /** + * Displays the system performance page. + * + * @return array + * A render array containing the cache-clear form and performance + * configuration form. + */ + public function build(): array { + return [ + 'cache_clear' => $this->formBuilder()->getForm(ClearCacheForm::class), + 'performance' => $this->formBuilder()->getForm(PerformanceForm::class), + ]; + } + +} diff --git a/core/modules/system/src/Form/ClearCacheForm.php b/core/modules/system/src/Form/ClearCacheForm.php new file mode 100644 index 0000000000000000000000000000000000000000..f8d3d5638f9c57119b1bad178d4936e538c46a0a --- /dev/null +++ b/core/modules/system/src/Form/ClearCacheForm.php @@ -0,0 +1,49 @@ +<?php + +namespace Drupal\system\Form; + +use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormStateInterface; + +/** + * Clear caches for this site. + * + * @internal + */ +class ClearCacheForm extends FormBase { + + /** + * {@inheritdoc} + */ + public function getFormId() { + return 'system_clear_cache'; + } + + /** + * {@inheritdoc} + */ + public function buildForm(array $form, FormStateInterface $form_state) { + + $form['clear_cache'] = [ + '#type' => 'details', + '#title' => $this->t('Clear cache'), + '#open' => TRUE, + ]; + + $form['clear_cache']['clear'] = [ + '#type' => 'submit', + '#value' => $this->t('Clear all caches'), + ]; + + return $form; + } + + /** + * Clears the caches. + */ + public function submitForm(array &$form, FormStateInterface $form_state) { + drupal_flush_all_caches(); + $this->messenger()->addStatus($this->t('Caches cleared.')); + } + +} diff --git a/core/modules/system/src/Form/PerformanceForm.php b/core/modules/system/src/Form/PerformanceForm.php index c76aaf40181763d02d4c2b2029f7d3448ad883c1..cf26b6dbf1f3c1a226e1328cd116b22950c24601 100644 --- a/core/modules/system/src/Form/PerformanceForm.php +++ b/core/modules/system/src/Form/PerformanceForm.php @@ -104,18 +104,6 @@ public function buildForm(array $form, FormStateInterface $form_state) { $config = $this->config('system.performance'); - $form['clear_cache'] = [ - '#type' => 'details', - '#title' => $this->t('Clear cache'), - '#open' => TRUE, - ]; - - $form['clear_cache']['clear'] = [ - '#type' => 'submit', - '#value' => $this->t('Clear all caches'), - '#submit' => ['::submitCacheClear'], - ]; - $form['caching'] = [ '#type' => 'details', '#title' => $this->t('Caching'), @@ -185,12 +173,4 @@ public function submitForm(array &$form, FormStateInterface $form_state) { parent::submitForm($form, $form_state); } - /** - * Clears the caches. - */ - public function submitCacheClear(array &$form, FormStateInterface $form_state) { - drupal_flush_all_caches(); - $this->messenger()->addStatus($this->t('Caches cleared.')); - } - } diff --git a/core/modules/system/system.routing.yml b/core/modules/system/system.routing.yml index 3b7c5c48968693cfbc2199749293522db12f2ee7..9e01d58469e7f566a677b613c9d5f59a742906ee 100644 --- a/core/modules/system/system.routing.yml +++ b/core/modules/system/system.routing.yml @@ -177,7 +177,7 @@ system.logging_settings: system.performance_settings: path: '/admin/config/development/performance' defaults: - _form: '\Drupal\system\Form\PerformanceForm' + _controller: '\Drupal\system\Controller\PerformanceController::build' _title: 'Performance' requirements: _permission: 'administer site configuration'