You are here

public function ResourceNode::entityPreSave in RESTful 7.2

Overrides ResourceEntity::entityPreSave().

Set the node author and other defaults.

File

src/Plugin/resource/ResourceNode.php, line 18
Contains Drupal\restful\Plugin\resource\ResourceNode.

Class

ResourceNode

Namespace

Drupal\restful\Plugin\resource

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;
}