diff --git a/core/modules/system/src/Form/PerformanceForm.php b/core/modules/system/src/Form/PerformanceForm.php index 2ec5043589050bc49580b2261dbb6648a9bacf5b..0e5c7840842e6bedcbf8193854e38770c9b03b6a 100644 --- a/core/modules/system/src/Form/PerformanceForm.php +++ b/core/modules/system/src/Form/PerformanceForm.php @@ -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://';