Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Node.php

function Node::preSave

Overrides ContentEntityBase::preSave

File

core/modules/node/src/Entity/Node.php, line 115

Class

Node
Defines the node entity class.

Namespace

Drupal\node\Entity

Code

public function preSave(EntityStorageInterface $storage) {
    parent::preSave($storage);
    foreach (array_keys($this->getTranslationLanguages()) as $langcode) {
        $translation = $this->getTranslation($langcode);
        // If no owner has been set explicitly, make the anonymous user the owner.
        if (!$translation->getOwner()) {
            $translation->setOwnerId(0);
        }
    }
    // If no revision author has been set explicitly, make the node owner the
    // revision author.
    if (!$this->getRevisionUser()) {
        $this->setRevisionUserId($this->getOwnerId());
    }
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal