public function ActionLinkHelper::unflagHelper in Flag Lists 4.0.x
Same name and namespace in other branches
- 8 src/Controller/ActionLinkHelper.php \Drupal\flag_lists\Controller\ActionLinkHelper::unflagHelper()
Helper function for unflag ActionLinks.
Parameters
\Drupal\flag\FlagInterface $flag: The flag to unflag.
string $entity_id: The entity id to remove the flag list item from.
string $flag_list: The flag list to remove the flag list item from.
File
- src/
Controller/ ActionLinkHelper.php, line 79
Class
- ActionLinkHelper
- Helper class for ActionLink Controller.
Namespace
Drupal\flag_lists\ControllerCode
public function unflagHelper(FlagInterface $flag, $entity_id, $flag_list) {
// Remove the corresponding Flag List Items.
$baseflag = $flag
->id();
$ids = $this->flagListsService
->getFlagListItemIds($baseflag, $flag_list, $entity_id);
foreach ($ids as $id) {
$flagListItem = \Drupal::entityTypeManager()
->getStorage('flag_list_item')
->load($id);
$flagListItem
->delete();
}
}