Skip to content

Commit

Permalink
Add an entitySave() method to DataProviderEntity.
Browse files Browse the repository at this point in the history
  • Loading branch information
jsacksick committed Apr 27, 2018
1 parent a148298 commit faaea06
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/Plugin/resource/DataProvider/DataProviderEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,13 @@ public function canonicalPath($path) {
*/
public function entityPreSave(\EntityDrupalWrapper $wrapper) {}

/**
* {@inheritdoc}
*/
public function entitySave(\EntityDrupalWrapper $wrapper) {
$wrapper->save();
}

/**
* {@inheritdoc}
*/
Expand Down Expand Up @@ -1057,8 +1064,7 @@ protected function setPropertyValues(\EntityDrupalWrapper $wrapper, $object, $re
$this->entityPreSave($interpreter->getWrapper());

$this->entityValidate($interpreter->getWrapper());

$wrapper->save();
$this->entitySave($interpreter->getWrapper());
}

/**
Expand Down
10 changes: 10 additions & 0 deletions src/Plugin/resource/DataProvider/DataProviderEntityInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@ interface DataProviderEntityInterface extends DataProviderInterface {
*/
public function entityPreSave(\EntityDrupalWrapper $wrapper);

/**
* Save an entity.
*
* @param \EntityDrupalWrapper $wrapper
* The wrapped entity.
*
* @throws BadRequestException
*/
public function entitySave(\EntityDrupalWrapper $wrapper);

/**
* Validate an entity before it is saved.
*
Expand Down

0 comments on commit faaea06

Please sign in to comment.