Skip to content
Snippets Groups Projects

Issue #2962763 by lokapujya, drupal-ramesh, KapilV, vsujeetkumar, Andrew...

Files
2
@@ -2,6 +2,7 @@
namespace Drupal\statistics\Plugin\views\field;
use Drupal\Core\Cache\CacheableDependencyInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\views\Attribute\ViewsField;
use Drupal\views\Plugin\views\field\NumericField;
@@ -12,7 +13,7 @@ use Drupal\views\Plugin\views\field\NumericField;
* @ingroup views_field_handlers
*/
#[ViewsField("statistics_numeric")]
class StatisticsNumeric extends NumericField {
class StatisticsNumeric extends NumericField implements CacheableDependencyInterface {
/**
* {@inheritdoc}
@@ -21,4 +22,26 @@ class StatisticsNumeric extends NumericField {
return $account->hasPermission('view post access counter');
}
/**
* {@inheritdoc}
*/
public function getCacheMaxAge() {
// @todo Consider caching node view statistics for a certain period.
return 0;
}
/**
* {@inheritdoc}
*/
public function getCacheContexts() {
return ['user.permissions'];
}
/**
* {@inheritdoc}
*/
public function getCacheTags() {
return [];
}
}
Loading