From b1b2df1dda9286366bf9c1a92275d8ae5c051da3 Mon Sep 17 00:00:00 2001
From: "Matthew Wire (MJW Consulting)" <mjw@mjwconsult.co.uk>
Date: Wed, 6 Nov 2019 16:21:06 +0000
Subject: [PATCH] Add setEntityId() to entityForm

---
 CRM/Contribute/Form/AbstractEditPayment.php |  7 -------
 CRM/Core/Form/EntityFormTrait.php           | 16 ++++++++++++++++
 CRM/Member/Form.php                         |  6 ------
 CRM/Member/Form/MembershipConfig.php        |  2 +-
 CRM/UF/Form/Group.php                       |  7 -------
 5 files changed, 17 insertions(+), 21 deletions(-)

diff --git a/CRM/Contribute/Form/AbstractEditPayment.php b/CRM/Contribute/Form/AbstractEditPayment.php
index 04be631bb138..9c5ca6cf14ed 100644
--- a/CRM/Contribute/Form/AbstractEditPayment.php
+++ b/CRM/Contribute/Form/AbstractEditPayment.php
@@ -77,13 +77,6 @@ class CRM_Contribute_Form_AbstractEditPayment extends CRM_Contact_Form_Task {
    */
   protected $_paymentObject;
 
-  /**
-   * The id of the contribution that we are processing.
-   *
-   * @var int
-   */
-  public $_id;
-
   /**
    * Entity that $this->_id relates to.
    *
diff --git a/CRM/Core/Form/EntityFormTrait.php b/CRM/Core/Form/EntityFormTrait.php
index 15ff60830a79..1403d7ebfd53 100644
--- a/CRM/Core/Form/EntityFormTrait.php
+++ b/CRM/Core/Form/EntityFormTrait.php
@@ -16,6 +16,13 @@
  */
 trait CRM_Core_Form_EntityFormTrait {
 
+  /**
+   * The id of the object being edited / created.
+   *
+   * @var int
+   */
+  protected $_id;
+
   /**
    * The entity subtype ID (eg. for Relationship / Activity)
    *
@@ -71,6 +78,15 @@ public function getEntityId() {
     return $this->_id;
   }
 
+  /**
+   * Set the entity ID
+   *
+   * @param int $id The entity ID
+   */
+  public function setEntityId($id) {
+    $this->_id = $id;
+  }
+
   /**
    * Should custom data be suppressed on this form.
    *
diff --git a/CRM/Member/Form.php b/CRM/Member/Form.php
index 40e66ca63f3d..1408396dafdd 100644
--- a/CRM/Member/Form.php
+++ b/CRM/Member/Form.php
@@ -22,12 +22,6 @@
 class CRM_Member_Form extends CRM_Contribute_Form_AbstractEditPayment {
 
   use CRM_Core_Form_EntityFormTrait;
-  /**
-   * The id of the object being edited / created
-   *
-   * @var int
-   */
-  public $_id;
 
   /**
    * Membership Type ID
diff --git a/CRM/Member/Form/MembershipConfig.php b/CRM/Member/Form/MembershipConfig.php
index e0b349730db9..cd891f45b932 100644
--- a/CRM/Member/Form/MembershipConfig.php
+++ b/CRM/Member/Form/MembershipConfig.php
@@ -28,7 +28,7 @@ class CRM_Member_Form_MembershipConfig extends CRM_Core_Form {
    *
    * @var int
    */
-  public $_id;
+  protected $_id;
 
   /**
    * The name of the BAO object for this form.
diff --git a/CRM/UF/Form/Group.php b/CRM/UF/Form/Group.php
index f531dfbbb840..90f7528c4973 100644
--- a/CRM/UF/Form/Group.php
+++ b/CRM/UF/Form/Group.php
@@ -90,13 +90,6 @@ public function getDefaultEntity() {
     return 'UFGroup';
   }
 
-  /**
-   * The form id saved to the session for an update.
-   *
-   * @var int
-   */
-  protected $_id;
-
   /**
    * The title for group.
    *