Skip to main content
removed "Drupal" and tags from the title
Link
avpaderno
  • 97.9k
  • 15
  • 164
  • 284

How todo I get low level data from flagthe Flag module in Drupal 8?

deleted 8 characters in body
Source Link

Is it possible that I canto 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.

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.

Is it possible to 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.

Source Link

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.