Commit 733de4d5 authored by Gorodkov Denis's avatar Gorodkov Denis

add cache context

parent c62384ff
...@@ -3,8 +3,10 @@ ...@@ -3,8 +3,10 @@
* @file * @file
* Main file for hooks and custom functions. * Main file for hooks and custom functions.
*/ */
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Drupal\Core\Cache\CacheableMetadata;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Drupal\Core\Entity\EntityInterface;
/** /**
* Implements hook_cron(). * Implements hook_cron().
*/ */
...@@ -69,3 +71,16 @@ function mymodule_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_ ...@@ -69,3 +71,16 @@ function mymodule_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_
$form["actions"]["reset"]["#access"] = true; $form["actions"]["reset"]["#access"] = true;
} }
} }
/**
* Implements hook_node_view().
*/
function mymodule_node_view(array &$build, \Drupal\Core\Entity\EntityInterface $entity, \Drupal\Core\Entity\Display\EntityViewDisplayInterface $display, $view_mode) {
$bundle = $entity->bundle();
if ($bundle == 'people') {
$build['#cache']['contexts'][] = 'url.query_args';
$entity->save();
}
}
<?php <?php
use Drupal\Core\Cache\CacheableMetadata;
use Drupal\Core\Entity\EntityInterface;
/** /**
* @file * @file
* Bootstrap sub-theme. * Bootstrap sub-theme.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment