You are here

function prevnext_node_presave in Prevnext 2.x

Same name and namespace in other branches
  1. 8 prevnext.module \prevnext_node_presave()
  2. 2.0.x prevnext.module \prevnext_node_presave()

Implements hook_ENTITY_TYPE_presave().

File

./prevnext.module, line 128
Contains prevnext.module.

Code

function prevnext_node_presave(EntityInterface $entity) {
  $config = \Drupal::config('prevnext.settings');
  $enabled_nodetypes = $config
    ->get('prevnext_enabled_nodetypes');
  if (in_array($entity
    ->bundle(), $enabled_nodetypes)) {

    // We are saving a node of a type with prevnext enabled, so invalidate
    // all cached rendered output of other nodes of this type with our tag.
    Cache::invalidateTags([
      'prevnext-' . $entity
        ->bundle(),
    ]);
  }
}