You are here

public function GroupContentController::addForm in Group 8

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

Provides the group content submission form.

Parameters

\Drupal\group\Entity\GroupInterface $group: The group to add the group content to.

string $plugin_id: The group content enabler to add content with.

Return value

array A group submission form.

File

src/Entity/Controller/GroupContentController.php, line 227

Class

GroupContentController
Returns responses for GroupContent routes.

Namespace

Drupal\group\Entity\Controller

Code

public function addForm(GroupInterface $group, $plugin_id) {

  /** @var \Drupal\group\Plugin\GroupContentEnablerInterface $plugin */
  $plugin = $group
    ->getGroupType()
    ->getContentPlugin($plugin_id);
  $values = [
    'type' => $plugin
      ->getContentTypeConfigId(),
    'gid' => $group
      ->id(),
  ];
  $group_content = $this
    ->entityTypeManager()
    ->getStorage('group_content')
    ->create($values);
  return $this->entityFormBuilder
    ->getForm($group_content, 'add');
}