You are here

public function RestfulEntityBaseNode::entityPreSave in RESTful 7

Overrides RestfulEntityBase::entityPreSave().

Set the node author and other defaults.

Overrides RestfulEntityBase::entityPreSave

File

plugins/restful/RestfulEntityBaseNode.php, line 41
Contains RestfulEntityBaseNode.

Class

RestfulEntityBaseNode
A base implementation for "Node" entity type.

Code

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

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