Skip to content
Snippets Groups Projects
Commit 9a0e4ac4 authored by Erik Stielstra's avatar Erik Stielstra Committed by Erik Stielstra
Browse files

Issue #3273254 by Sutharsan: Cache tags missing

parent 0deb5357
No related branches found
No related tags found
No related merge requests found
......@@ -53,6 +53,7 @@ class RadioactivityLazyBuilder implements TrustedCallbackInterface {
*/
public function buildReferencedValue(int $entityId, ?int $decimals = NULL, string $decimalSeparator = '.', string $thousandsSeparator = ','): array {
/** @var \Drupal\radioactivity\RadioactivityInterface $entity */
$entity = $this->radioactivityStorage->load($entityId);
if (empty($entity)) {
return [];
......@@ -65,7 +66,10 @@ class RadioactivityLazyBuilder implements TrustedCallbackInterface {
$value = number_format($entity->getEnergy(), $decimals, $decimalSeparator, $thousandsSeparator);
}
return ['#markup' => $value];
return [
'#markup' => $value,
'#cache' => ['tags' => $entity->getCacheTags()],
];
}
}
......@@ -33,6 +33,8 @@ class RadioactivityLazyBuilderTest extends UnitTestCase {
$radioactivityEntity = $this->prophesize(RadioactivityInterface::class);
$radioactivityEntity->getEnergy()
->willReturn($energy);
$radioactivityEntity->getCacheTags()
->willReturn(['radioactivity:1']);
$radioactivityStorage = $this->prophesize(EntityStorageInterface::class);
$radioactivityStorage->load(Argument::is(0))
......@@ -83,10 +85,22 @@ class RadioactivityLazyBuilderTest extends UnitTestCase {
public function providerBuildReferencedValue() {
return [
[0, 0, []],
[1, 0, ['#markup' => '9']],
[1, 1, ['#markup' => '9.1']],
[1, 2, ['#markup' => '9.12']],
[1, NULL, ['#markup' => '9.12345']],
[1, 0, [
'#markup' => '9',
'#cache' => ['tags' => ['radioactivity:1']],
]],
[1, 1, [
'#markup' => '9.1',
'#cache' => ['tags' => ['radioactivity:1']],
]],
[1, 2, [
'#markup' => '9.12',
'#cache' => ['tags' => ['radioactivity:1']],
]],
[1, NULL, [
'#markup' => '9.12345',
'#cache' => ['tags' => ['radioactivity:1']],
]],
];
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment