You are here

public function Group::addContent in Group 8

Same name and namespace in other branches
  1. 2.0.x src/Entity/Group.php \Drupal\group\Entity\Group::addContent()

Adds a content entity as a group content entity.

Parameters

\Drupal\Core\Entity\ContentEntityInterface $entity: The content entity to add to the group.

string $plugin_id: The ID of the content enabler plugin to add the entity with.

array $values: (optional) Extra values to add to the group content relationship. You cannot overwrite the group ID (gid) or entity ID (entity_id).

Overrides GroupInterface::addContent

1 call to Group::addContent()
Group::addMember in src/Entity/Group.php
Adds a user as a member of the group.

File

src/Entity/Group.php, line 154

Class

Group
Defines the Group entity.

Namespace

Drupal\group\Entity

Code

public function addContent(ContentEntityInterface $entity, $plugin_id, $values = []) {
  $storage = $this
    ->groupContentStorage();
  $group_content = $storage
    ->createForEntityInGroup($entity, $this, $plugin_id, $values);
  $storage
    ->save($group_content);
}