Skip to content

Commit

Permalink
Merge pull request #34 from webflo/entity-delete
Browse files Browse the repository at this point in the history
Skip entity delete for non-existing entities

Signed-off-by: Jonathan Hedstrom <[email protected]>
  • Loading branch information
jhedstrom committed Jun 1, 2015
1 parent c5f6715 commit 9729a72
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/Drupal/Driver/Cores/Drupal8.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Drupal\node\Entity\Node;
use Drupal\node\NodeInterface;
use Drupal\taxonomy\Entity\Term;
use Drupal\taxonomy\TermInterface;
use Symfony\Component\HttpFoundation\Request;

/**
Expand Down Expand Up @@ -70,7 +71,9 @@ public function nodeCreate($node) {
*/
public function nodeDelete($node) {
$node = $node instanceof NodeInterface ? $node : Node::load($node->nid);
$node->delete();
if ($node instanceof NodeInterface) {
$node->delete();
}
}

/**
Expand Down Expand Up @@ -299,8 +302,10 @@ public function termCreate(\stdClass $term) {
* {@inheritDoc}
*/
public function termDelete(\stdClass $term) {
$term = Term::load($term->tid);
$term->delete();
$term = $term instanceof TermInterface ? $term : Term::load($term->tid);
if ($term instanceof TermInterface) {
$term->delete();
}
}

/**
Expand Down

0 comments on commit 9729a72

Please sign in to comment.