public function ParagraphsItemController::add in Paragraphs table 8
Provides the paragraphs item submission form.
Parameters
\Drupal\paragraphs\Entity\Paragraph $paragraph: The paragraphs entity for the paragraph item.
string $host_type: The type of the entity hosting the paragraph item.
int $host_id: The id of the entity hosting the paragraph item.
Return value
array A paragraph item submission form.
@todo additional fields
Throws
\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
\Drupal\Component\Plugin\Exception\PluginNotFoundException
1 string reference to 'ParagraphsItemController::add'
File
- src/
Controller/ ParagraphsItemController.php, line 31
Class
- ParagraphsItemController
- Returns responses for paragraphs item routes.
Namespace
Drupal\paragraphs_table\ControllerCode
public function add(Paragraph $paragraph, $host_type, $host_id) {
$host = $this
->entityTypeManager()
->getStorage($host_type)
->load($host_id);
$paragraphs_item = $this
->entityTypeManager()
->getStorage('paragraph')
->create([
'field_name' => $paragraph
->id(),
'type' => $host_type,
'revision_id' => 0,
]);
return $this
->entityFormBuilder()
->getForm($paragraphs_item);
}