From 9729a726835d1f3285dba03b7adbd7430d621fa4 Mon Sep 17 00:00:00 2001 From: Jonathan Hedstrom Date: Mon, 1 Jun 2015 10:41:21 -0700 Subject: [PATCH] Merge pull request #34 from webflo/entity-delete Skip entity delete for non-existing entities Signed-off-by: Jonathan Hedstrom --- src/Drupal/Driver/Cores/Drupal8.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Drupal/Driver/Cores/Drupal8.php b/src/Drupal/Driver/Cores/Drupal8.php index bad6ca71..1c699280 100644 --- a/src/Drupal/Driver/Cores/Drupal8.php +++ b/src/Drupal/Driver/Cores/Drupal8.php @@ -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; /** @@ -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(); + } } /** @@ -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(); + } } /**