function Node::preSave
Same name in other branches
- 9 core/modules/node/src/Entity/Node.php \Drupal\node\Entity\Node::preSave()
- 8.9.x core/modules/node/src/Entity/Node.php \Drupal\node\Entity\Node::preSave()
- 11.x core/modules/node/src/Entity/Node.php \Drupal\node\Entity\Node::preSave()
Overrides ContentEntityBase::preSave
File
-
core/
modules/ node/ src/ Entity/ Node.php, line 104
Class
- Node
- Defines the node entity class.
Namespace
Drupal\node\EntityCode
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());
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.