public function ActionLinkHelper::flagHelper in Flag Lists 8
Same name and namespace in other branches
- 4.0.x src/Controller/ActionLinkHelper.php \Drupal\flag_lists\Controller\ActionLinkHelper::flagHelper()
Helper function for flag ActionLinks.
Parameters
\Drupal\flag\FlagInterface $flag: The flag to flag.
string $entity_id: The entity id to add the flag list item to.
string $flag_list: The flag list to add the flag list item to.
File
- src/
Controller/ ActionLinkHelper.php, line 54
Class
- ActionLinkHelper
- Helper class for ActionLink Controller.
Namespace
Drupal\flag_lists\ControllerCode
public function flagHelper(FlagInterface $flag, $entity_id, $flag_list) {
// Create the Flag List Item.
$flag_list_name = $this->flagListsService
->getFlaggingCollectionById($flag_list)
->getName();
$flag_list_item = FlagListItem::create([
'entity_id' => $entity_id,
'type' => $flag
->getFlaggableEntityTypeId(),
'baseflag' => $flag
->id(),
'flag_list' => $flag_list,
'name' => $flag_list_name . ' ' . $entity_id,
]);
$flag_list_item
->save();
}