/** * Get the revision owner for an ContentEntity. * * Need because 2 possible interfaces support this. * * @param \Drupal\Core\Entity\ContentEntityInterface $entity * * @return \Drupal\user\UserInterface|NULL */ protected function getRevisionOwner(ContentEntityInterface $entity) { if ($entity instanceof NodeInterface) { return $entity->getRevisionAuthor(); } elseif ($this->implementsInterface($entity, ['Drupal\\entity\\Revision\\EntityRevisionLogInterface'])) { /** @var \Drupal\entity\Revision\EntityRevisionLogInterface $entity */ return $entity->getRevisionUser(); } return NULL; }