public function DemoNode::createGroupContent in Open Social 8
Same name and namespace in other branches
- 8.9 modules/custom/social_demo/src/DemoNode.php \Drupal\social_demo\DemoNode::createGroupContent()
- 8.2 modules/custom/social_demo/src/DemoNode.php \Drupal\social_demo\DemoNode::createGroupContent()
- 8.3 modules/custom/social_demo/src/DemoNode.php \Drupal\social_demo\DemoNode::createGroupContent()
- 8.4 modules/custom/social_demo/src/DemoNode.php \Drupal\social_demo\DemoNode::createGroupContent()
- 8.5 modules/custom/social_demo/src/DemoNode.php \Drupal\social_demo\DemoNode::createGroupContent()
- 8.6 modules/custom/social_demo/src/DemoNode.php \Drupal\social_demo\DemoNode::createGroupContent()
- 8.7 modules/custom/social_demo/src/DemoNode.php \Drupal\social_demo\DemoNode::createGroupContent()
- 8.8 modules/custom/social_demo/src/DemoNode.php \Drupal\social_demo\DemoNode::createGroupContent()
- 10.3.x modules/custom/social_demo/src/DemoNode.php \Drupal\social_demo\DemoNode::createGroupContent()
- 10.0.x modules/custom/social_demo/src/DemoNode.php \Drupal\social_demo\DemoNode::createGroupContent()
- 10.1.x modules/custom/social_demo/src/DemoNode.php \Drupal\social_demo\DemoNode::createGroupContent()
- 10.2.x modules/custom/social_demo/src/DemoNode.php \Drupal\social_demo\DemoNode::createGroupContent()
Creates a group content.
Parameters
\Drupal\node\NodeInterface $entity: Object of a node.
string $uuid: UUID of a group.
1 call to DemoNode::createGroupContent()
- DemoNode::createContent in modules/
custom/ social_demo/ src/ DemoNode.php - Creates content.
File
- modules/
custom/ social_demo/ src/ DemoNode.php, line 171
Class
- DemoNode
- Class DemoNode.
Namespace
Drupal\social_demoCode
public function createGroupContent(NodeInterface $entity, $uuid) {
// Load the group.
$groups = $this->groupStorage
->loadByProperties([
'uuid' => $uuid,
]);
if ($groups) {
$group = current($groups);
// Get the group content plugin.
$plugin_id = 'group_node:' . $entity
->bundle();
$plugin = $group
->getGroupType()
->getContentPlugin($plugin_id);
$group_content = GroupContent::create([
'type' => $plugin
->getContentTypeConfigId(),
'gid' => $group
->id(),
'entity_id' => $entity
->id(),
]);
$group_content
->save();
}
}