3
0
Fork 0
mirror of https://github.com/farmOS/farmOS.git synced 2024-02-23 11:37:38 +01:00

Add the log_list:bundle cache tag to the access result.

This commit is contained in:
paul121 2021-05-21 10:47:55 -07:00
parent 838cd33c15
commit a2cb3b26ab

View file

@ -56,7 +56,14 @@ class FarmAssetLogViewsAccessCheck implements AccessInterface {
->condition('asset.entity.id', $asset_id)
->aggregate('id', 'COUNT')
->execute();
return (!empty((int) $result[0]['id_count'] ?? 0)) ? AccessResult::allowed() : AccessResult::forbidden();
// Determine access based on the log count.
$log_count = (int) $result[0]['id_count'] ?? 0;
$access = empty($log_count) ? AccessResult::forbidden() : AccessResult::allowed();
// Invalidate the access result when logs of this bundle are changed.
$access->addCacheTags(["log_list:$log_type"]);
return $access;
}
}