Commit 495b781e authored by Artem Dmitriiev's avatar Artem Dmitriiev Committed by João Ventura
Browse files

Issue #3317590 by a.dmitriiev, jcnventura: Don't clear all caches on settings form submit

parent b41537b1
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@
 * Functions and hooks for the frontend_editing module.
 */

use Drupal\Core\Cache\CacheableMetadata;
use Drupal\Core\Entity\Display\EntityViewDisplayInterface;
use Drupal\Core\Entity\EntityForm;
use Drupal\Core\Entity\EntityInterface;
@@ -23,6 +24,8 @@ function frontend_editing_entity_view_alter(&$build, EntityInterface $entity, En
  }

  $config = \Drupal::configFactory()->get('frontend_editing.settings');
  $cacheable_metadata = new CacheableMetadata();
  $cacheable_metadata->addCacheableDependency($config);
  $supported_entity_types = $config->get('entity_types');
  // If a value is 0 (for disabled) a search will evaluate to TRUE, e.g.
  // "'key' == 0" evaluates to TRUE, therefore we need to perform strict search.
@@ -31,11 +34,11 @@ function frontend_editing_entity_view_alter(&$build, EntityInterface $entity, En
  }

  // Only do this, if user has access to frontend editing.
  $build['#cache']['contexts'][] = 'user.permissions';
  $cacheable_metadata->addCacheContexts(['user.permissions']);
  if (!\Drupal::currentUser()->hasPermission('access frontend editing') || ($entity instanceof RevisionableInterface && !$entity->isLatestRevision()) || !$entity->access('update')) {
    return;
  }

  $cacheable_metadata->applyTo($build);
  // Add the editing url as a data attribute.
  $url = Url::fromRoute('frontend_editing.form', [
    'type' => $entity->getEntityTypeId(),
+0 −1
Original line number Diff line number Diff line
@@ -118,7 +118,6 @@ class SettingsForm extends ConfigFormBase {
      ->set('sidebar_width', $form_state->getValue('sidebar_width'))
      ->set('full_width', $form_state->getValue('full_width'))
      ->save();
    drupal_flush_all_caches();
    parent::submitForm($form, $form_state);
  }