Can't use getParentEntity() in hook_entity_insert()? When is the parent entity set?

Created on 20 February 2017, almost 8 years ago
Updated 17 March 2023, almost 2 years ago

I need to do some processing after a new paragraph is saved, using the paragraph's parent entity. If I do this:

/**
 * Implements hook_ENTITY_TYPE_insert().
 */
function MYMODULE_paragraph_insert(EntityInterface $entity) {
  $parent = $entity->getParentEntity();
}

$parent is NULL. When is getParentEntity() available?

💬 Support request
Status

Needs work

Version

1.0

Component

Code

Created by

🇳🇿New Zealand john pitcairn

Live updates comments and jobs are added and updated live.
  • Needs documentation

    A documentation change is requested elsewhere. For Drupal core (and possibly other projects), once the change has been committed, this status should be recorded in a change record node.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024