RemoveContent() function appears to be missing

Created on 15 July 2019, over 5 years ago
Updated 8 August 2023, over 1 year ago

In order to add a node to a group, I use the following code.

$group->addContent($node, 'group_node:article');

Now, for removing content from a group, I have tried

$group->removeContent($node, 'group_node:article');

and

$group->removeContent($node);

without success. All I obtained is the following error message.

Error: Call to undefined method Drupal\group\Entity\Group::removeContent() in Drupal\my_valetop_extras\Plugin\WebformHandler\CustomWebformHandler->submitForm()

Finally, I have managed to remove content from a group using this code.

$type = 'group_node:' . $node->getType();
$current_node = $group->getContent($type, ['entity_id' => $node_id]);
$content = array_values($current_node)[0];
$content->delete();

I still believe I can remove a single node from a group with a simple line of code.

Can you please add such function to the group module ? Same idea as removeMember() which is the inverse of addMember()

Thank you,

✨ Feature request
Status

Needs review

Version

1.0

Component

Code

Created by

πŸ‡±πŸ‡§Lebanon C.E.A

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

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