When building this blog I decided to use the core module statistics to display the view count on blog posts. Because some of my older blog posts have had a lot of views, the counter on those blog post views had grown quite large. For making those large numbers more readable it would be nice that those numbers would be displayed with thousands-seperators, just as can be accomplished with the PHP function number_format() or, even better, with the NumberFormatter class. The statistics module does not do that.
As it turns out Drupal 8 core does not support that either, and a sole module that offers this functionality has no Drupal 8 version. I decided to make a solution specifically for the statistics module. That module implements the hook hook_node_links_alter() in the statistics.module file to add the view count to the list of node links (as text). So I set out to create a copy of this hook that would override this particular hook.
The module to which I will add this hook will be named mystatistics:
# mystatistics.info.yml name: 'My Statistics' type: module description: 'Module to override the display of the Statistics module.' package: Other version: '1.0' core: '8.x' dependencies: - statistics
In the mystatistics.module file I added the following code: