How to get low level data from flag module in Drupal 8?


Is it possible that I can get the following raw, low level data from the Flag Module and/or it’s services?

  • Flagging count as integer
  • URL to flag/unflag as a string
  • Current user’s flagging status as boolean

I already know that I can do this:

$flag_link = Drupal::service('flag.link_builder')->build('node',$nid,'bookmark');

But it will output the full blown markup with Ajax and everything.

I’ve done this:

$flag_service = Drupal::service('flag.count');
$counts = $flag_service->getEntityFlagCounts($node);

But I can’t actually figure out what exactly $counts contains, I definitely can’t output it as an integer on my template, I get an error.