add a service method to get all of a user's flagged entities for a given flag

Created on 19 July 2016, about 9 years ago
Updated 18 August 2025, 5 days ago

Hallo,

as I see with the latest dev update the function getFlaggings get replaced with getEntityFlaggings.
But previously I was able to call this function without an entity. Now I cannot accomplish this anymore.
previously:

$flag = \Drupal::service('flag')->getFlagById('following');
$user = \Drupal::currentUser();	
$following = \Drupal::service('flag')->getFlaggings($flag, NULL, $user);

If I call now:

$flag = \Drupal::service('flag')->getFlagById('following');
$user = \Drupal::currentUser();	
$following = \Drupal::service('flag')->getEntityFlaggings($flag, NULL, $user);

I get:
Recoverable fatal error: Argument 2 passed to Drupal\flag\FlagService::getEntityFlaggings() must implement interface Drupal\Core\Entity\EntityInterface, null given

Probably it's just my lack of knowlege, is there an easy way to create an empty instance of Entity for passing?
The logic of getEntityFlaggings would be fine with an empty object.

Thanks,
Matthias

Feature request
Status

Active

Version

5.0

Component

Flag core

Created by

🇩🇪Germany mfrosch

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024