Added Entity and Entity Reference Revisions which got dropped somewhere along the...
[yaffs-website] / web / modules / contrib / entity_reference_revisions / src / EntityNeedsSaveTrait.php
diff --git a/web/modules/contrib/entity_reference_revisions/src/EntityNeedsSaveTrait.php b/web/modules/contrib/entity_reference_revisions/src/EntityNeedsSaveTrait.php
new file mode 100644 (file)
index 0000000..3304010
--- /dev/null
@@ -0,0 +1,39 @@
+<?php
+
+namespace Drupal\entity_reference_revisions;
+use Drupal\Core\Entity\EntityStorageInterface;
+
+/**
+ * Trait for EntityNeedsSaveInterface.
+ */
+trait EntityNeedsSaveTrait {
+
+  /**
+   * Whether the entity needs to be saved or not.
+   *
+   * @var bool
+   */
+  protected $needsSave = FALSE;
+
+  /**
+   * {@inheritdoc}
+   */
+  public function needsSave() {
+    return $this->needsSave;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function setNeedsSave($needs_save) {
+    $this->needsSave = $needs_save;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function postSave(EntityStorageInterface $storage, $update = TRUE) {
+    parent::postSave($storage, $update);
+    $this->setNeedsSave(FALSE);
+  }
+}