Skip to content
Snippets Groups Projects
Commit 4e43216f authored by catch's avatar catch
Browse files

Issue #2216161 by Wim Leers, alexpott, jhedstrom, borisson_, Berdir: Simplify...

Issue #2216161 by Wim Leers, alexpott, jhedstrom, borisson_, Berdir: Simplify performance settings page
parent b89bd0c9
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
......@@ -3,10 +3,12 @@
namespace Drupal\system\Form;
use Drupal\Core\Asset\AssetCollectionOptimizerInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Form\ConfigFormBase;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Datetime\DateFormatterInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
......@@ -37,6 +39,13 @@ class PerformanceForm extends ConfigFormBase {
*/
protected $jsCollectionOptimizer;
/**
* The module handler.
*
* @var \Drupal\Core\Extension\ModuleHandlerInterface
*/
protected $moduleHandler;
/**
* Constructs a PerformanceForm object.
*
......@@ -48,13 +57,16 @@ class PerformanceForm extends ConfigFormBase {
* The CSS asset collection optimizer service.
* @param \Drupal\Core\Asset\AssetCollectionOptimizerInterface $js_collection_optimizer
* The JavaScript asset collection optimizer service.
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
* The module handler.
*/
public function __construct(ConfigFactoryInterface $config_factory, DateFormatterInterface $date_formatter, AssetCollectionOptimizerInterface $css_collection_optimizer, AssetCollectionOptimizerInterface $js_collection_optimizer) {
public function __construct(ConfigFactoryInterface $config_factory, DateFormatterInterface $date_formatter, AssetCollectionOptimizerInterface $css_collection_optimizer, AssetCollectionOptimizerInterface $js_collection_optimizer, ModuleHandlerInterface $module_handler) {
parent::__construct($config_factory);
$this->dateFormatter = $date_formatter;
$this->cssCollectionOptimizer = $css_collection_optimizer;
$this->jsCollectionOptimizer = $js_collection_optimizer;
$this->moduleHandler = $module_handler;
}
/**
......@@ -65,7 +77,8 @@ public static function create(ContainerInterface $container) {
$container->get('config.factory'),
$container->get('date.formatter'),
$container->get('asset.css.collection_optimizer'),
$container->get('asset.js.collection_optimizer')
$container->get('asset.js.collection_optimizer'),
$container->get('module_handler')
);
}
......@@ -107,7 +120,6 @@ public function buildForm(array $form, FormStateInterface $form_state) {
'#type' => 'details',
'#title' => t('Caching'),
'#open' => TRUE,
'#description' => $this->t('Note: Drupal provides an internal page cache module that is recommended for small to medium-sized websites.'),
];
// Identical options to the ones for block caching.
// @see \Drupal\Core\Block\BlockBase::buildConfigurationForm()
......@@ -116,10 +128,14 @@ public function buildForm(array $form, FormStateInterface $form_state) {
$period[0] = '<' . t('no caching') . '>';
$form['caching']['page_cache_maximum_age'] = [
'#type' => 'select',
'#title' => t('Page cache maximum age'),
'#title' => t('Browser and proxy cache maximum age'),
'#default_value' => $config->get('cache.page.max_age'),
'#options' => $period,
'#description' => t('The maximum time a page can be cached by browsers and proxies. This is used as the value for max-age in Cache-Control headers.'),
'#description' => t('This is used as the value for max-age in Cache-Control headers.'),
];
$form['caching']['internal_page_cache'] = [
'#markup' => $this->t('Drupal provides an <a href=":module_enable">Internal Page Cache module</a> that is recommended for small to medium-sized websites.', [':module_enable' => Url::fromRoute('system.modules_list')->toString()]),
'#access' => !$this->moduleHandler->moduleExists('page_cache'),
];
$directory = 'public://';
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment