You are here

public function DataProviderNode::entityPreSave in RESTful 7.2

Allow manipulating the entity before it is saved.

Parameters

\EntityDrupalWrapper $wrapper: The unsaved wrapped entity.

Overrides DataProviderEntity::entityPreSave

File

src/Plugin/resource/DataProvider/DataProviderNode.php, line 42
Contains \Drupal\restful\Plugin\resource\DataProvider\DataProviderNode.

Class

DataProviderNode
Class DataProviderNode.

Namespace

Drupal\restful\Plugin\resource\DataProvider

Code

public function entityPreSave(\EntityDrupalWrapper $wrapper) {
  $node = $wrapper
    ->value();
  if (!empty($node->nid)) {

    // Node is already saved.
    return;
  }
  node_object_prepare($node);
  $node->uid = $this
    ->getAccount()->uid;
}