public function Paragraph::setParentEntity

Set the parent entity of the paragraph.

Parameters

\Drupal\Core\Entity\ContentEntityInterface $parent: The parent entity.

string $parent_field_name: The parent field name.

Return value

$this

Overrides ParagraphInterface::setParentEntity

File

paragraphs/src/Entity/Paragraph.php, line 146

Class

Paragraph
Defines the Paragraph entity.

Namespace

Drupal\paragraphs\Entity

Code

public function setParentEntity(ContentEntityInterface $parent, $parent_field_name) {
  $this
    ->set('parent_type', $parent
    ->getEntityTypeId());
  $this
    ->set('parent_id', $parent
    ->id());
  $this
    ->set('parent_field_name', $parent_field_name);
  return $this;
}