/**
  * @covers ::preSaveRevision
  */
 public function testPreSaveRevision()
 {
     // This method is internal, so check for errors on calling it only.
     $storage = $this->getMock('\\Drupal\\Core\\Entity\\EntityStorageInterface');
     $record = new \stdClass();
     // Our mocked entity->preSaveRevision() returns NULL, so assert that.
     $this->assertNull($this->entity->preSaveRevision($storage, $record));
 }
 /**
  * {@inheritdoc}
  */
 public function preSaveRevision(EntityStorageInterface $storage, \stdClass $record)
 {
     parent::preSaveRevision($storage, $record);
     if (!$this->isNewRevision() && isset($this->original) && (!isset($record->revision_log) || $record->revision_log === '')) {
         // If we are updating an existing entity without adding a new
         // revision and the user did not supply a revision log, keep the existing
         // one.
         $record->revision_log = $this->original->getRevisionLog();
     }
 }
 /**
  * {@inheritdoc}
  */
 public function preSaveRevision(EntityStorageInterface $storage, \stdClass $record)
 {
     parent::preSaveRevision($storage, $record);
     if (!$this->isNewRevision() && isset($this->original) && (!isset($record->revision_log) || $record->revision_log === '')) {
         // If we are updating an existing node 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 = $this->original->revision_log->value;
     }
 }
Beispiel #4
0
 /**
  * {@inheritdoc}
  */
 public function preSaveRevision(EntityStorageInterface $storage, \stdClass $record)
 {
     parent::preSaveRevision($storage, $record);
     if (!isset($record->revision_log)) {
         $record->revision_log = '';
     }
     $account = \Drupal::currentUser();
     $record->uid = $account->id();
 }
Beispiel #5
0
 /**
  * {@inheritdoc}
  */
 public function preSaveRevision(EntityStorageInterface $storage, \stdClass $record)
 {
     parent::preSaveRevision($storage, $record);
 }