You are here

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'
paragraphs_table.routing.yml in ./paragraphs_table.routing.yml
paragraphs_table.routing.yml

File

src/Controller/ParagraphsItemController.php, line 31

Class

ParagraphsItemController
Returns responses for paragraphs item routes.

Namespace

Drupal\paragraphs_table\Controller

Code

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);
}