public function Group::preSaveRevision in Group 8
Same name and namespace in other branches
- 2.0.x src/Entity/Group.php \Drupal\group\Entity\Group::preSaveRevision()
Acts on a revision before it gets saved.
Parameters
EntityStorageInterface $storage: The entity storage object.
object $record: The revision object.
Overrides ContentEntityBase::preSaveRevision
File
- src/
Entity/ Group.php, line 339
Class
- Group
- Defines the Group entity.
Namespace
Drupal\group\EntityCode
public function preSaveRevision(EntityStorageInterface $storage, \stdClass $record) {
parent::preSaveRevision($storage, $record);
// Core needs to make sure this happens for all entities as this piece of
// code is currently copy-pasted between Node, Media, Block, etc.
// @todo Keep an eye on this from time to time and see if we can remove it.
if (!$this
->isNewRevision() && isset($this->original) && empty($record->revision_log_message)) {
// If we are updating an existing group without adding a new revision, we
// need to make sure $entity->revision_log is reset whenever it is empty.
// Therefore, this code allows us to avoid clobbering an existing log
// entry with an empty one.
$record->revision_log_message = $this->original->revision_log_message->value;
}
if ($this
->isNewRevision() && empty($record->revision_created)) {
$record->revision_created = \Drupal::time()
->getRequestTime();
}
}