Change record status: 
Project: 
Introduced in branch: 
8.x-4.x
Introduced in version: 
Description: 

Previously there were two methods of flagging an entity, and two to unflag.

This is being unified and the methods which took ids as argument have been removed.

Before

FlagService::flagByObject(FlagInterface $flag, EntityInterface $entity, AccountInterface $account = NULL)
FlagService:: flag($flag_id, $entity_id, AccountInterface $account = NULL)

FlagService:: unflagByObject(FlagInterface $flag, EntityInterface $entity, AccountInterface $account = NULL)
FlagService::unflag($flag_id, $entity_id, AccountInterface $account = NULL) {

After

FlagService::flag(FlagInterface $flag, EntityInterface $entity, AccountInterface $account = NULL)
FlagService:: unflag(FlagInterface $flag, EntityInterface $entity, AccountInterface $account = NULL)

A pattern for developers wanting to convert their code :-

   $flagService = \Drupal::service();
   $flag = $flagService->getFlagById($flag_id);
   $entity = $flagService->getFlaggableById($flag, $entity_id);
   $flagService->flag($flag, $entity);
Impacts: 
Module developers