public function DataProviderComment::entityPreSave in RESTful 7.2
Allow manipulating the entity before it is saved.
Parameters
\EntityDrupalWrapper $wrapper: The unsaved wrapped entity.
Overrides DataProviderEntity::entityPreSave
File
- modules/
restful_example/ src/ Plugin/ resource/ comment/ DataProviderComment.php, line 64 - Contains \Drupal\restful_example\Plugin\resource\comment\DataProviderComment.
Class
Namespace
Drupal\restful_example\Plugin\resource\commentCode
public function entityPreSave(\EntityDrupalWrapper $wrapper) {
$comment = $wrapper
->value();
if (!empty($comment->cid)) {
// Comment is already saved.
return;
}
$comment->uid = $this
->getAccount()->uid;
}