Exemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     $this->cssCollectionOptimizer->deleteAll();
     $this->jsCollectionOptimizer->deleteAll();
     // This form allows page compression settings to be changed, which can
     // invalidate cached pages in the render cache, so it needs to be cleared on
     // form submit.
     $this->renderCache->deleteAll();
     $this->config('system.performance')->set('cache.page.use_internal', $form_state->getValue('cache'))->set('cache.page.max_age', $form_state->getValue('page_cache_maximum_age'))->set('response.gzip', $form_state->getValue('page_compression'))->set('css.preprocess', $form_state->getValue('preprocess_css'))->set('js.preprocess', $form_state->getValue('preprocess_js'))->save();
     parent::submitForm($form, $form_state);
 }
Exemplo n.º 2
0
 /**
  * {@inheritdoc}
  */
 public function uninstall(array $theme_list)
 {
     $extension_config = $this->configFactory->getEditable('core.extension');
     $theme_config = $this->configFactory->getEditable('system.theme');
     $list = $this->themeHandler->listInfo();
     foreach ($theme_list as $key) {
         if (!isset($list[$key])) {
             throw new \InvalidArgumentException("Unknown theme: {$key}.");
         }
         if ($key === $theme_config->get('default')) {
             throw new \InvalidArgumentException("The current default theme {$key} cannot be uninstalled.");
         }
         if ($key === $theme_config->get('admin')) {
             throw new \InvalidArgumentException("The current admin theme {$key} cannot be uninstalled.");
         }
         // Base themes cannot be uninstalled if sub themes are installed, and if
         // they are not uninstalled at the same time.
         // @todo https://www.drupal.org/node/474684 and
         //   https://www.drupal.org/node/1297856 themes should leverage the module
         //   dependency system.
         if (!empty($list[$key]->sub_themes)) {
             foreach ($list[$key]->sub_themes as $sub_key => $sub_label) {
                 if (isset($list[$sub_key]) && !in_array($sub_key, $theme_list, TRUE)) {
                     throw new \InvalidArgumentException("The base theme {$key} cannot be uninstalled, because theme {$sub_key} depends on it.");
                 }
             }
         }
     }
     $this->cssCollectionOptimizer->deleteAll();
     $current_theme_data = $this->state->get('system.theme.data', array());
     foreach ($theme_list as $key) {
         // The value is not used; the weight is ignored for themes currently.
         $extension_config->clear("theme.{$key}");
         // Update the current theme data accordingly.
         unset($current_theme_data[$key]);
         // Reset theme settings.
         $theme_settings =& drupal_static('theme_get_setting');
         unset($theme_settings[$key]);
         // Remove all configuration belonging to the theme.
         $this->configManager->uninstall('theme', $key);
     }
     // Don't check schema when uninstalling a theme since we are only clearing
     // keys.
     $extension_config->save(TRUE);
     $this->state->set('system.theme.data', $current_theme_data);
     // @todo Remove system_list().
     $this->themeHandler->refreshInfo();
     $this->resetSystem();
     $this->moduleHandler->invokeAll('themes_uninstalled', [$theme_list]);
 }