Add shared parent for ContributionRecur forms
authoreileen <emcnaughton@wikimedia.org>
Mon, 1 Apr 2019 23:24:56 +0000 (12:24 +1300)
committereileen <emcnaughton@wikimedia.org>
Mon, 1 Apr 2019 23:30:27 +0000 (12:30 +1300)
CRM/Contribute/Form/CancelSubscription.php
CRM/Contribute/Form/ContributionRecur.php [new file with mode: 0644]
CRM/Contribute/Form/UpdateBilling.php
CRM/Contribute/Form/UpdateSubscription.php

index c904f7fa94621428ce9a08bd2aef7f76adc9473f..e596ad54ee36f8bc2f0cff881751c5c7e812fa92 100644 (file)
@@ -34,7 +34,7 @@
 /**
  * This class provides support for canceling recurring subscriptions.
  */
-class CRM_Contribute_Form_CancelSubscription extends CRM_Core_Form {
+class CRM_Contribute_Form_CancelSubscription extends CRM_Contribute_Form_ContributionRecur {
   protected $_paymentProcessorObj = NULL;
 
   protected $_userContext = NULL;
@@ -43,10 +43,6 @@ class CRM_Contribute_Form_CancelSubscription extends CRM_Core_Form {
 
   protected $_mid = NULL;
 
-  protected $_coid = NULL;
-
-  protected $_crid = NULL;
-
   protected $_selfService = FALSE;
 
   /**
diff --git a/CRM/Contribute/Form/ContributionRecur.php b/CRM/Contribute/Form/ContributionRecur.php
new file mode 100644 (file)
index 0000000..8363ab5
--- /dev/null
@@ -0,0 +1,63 @@
+<?php
+/*
+ +--------------------------------------------------------------------+
+ | CiviCRM version 5                                                  |
+ +--------------------------------------------------------------------+
+ | Copyright CiviCRM LLC (c) 2004-2019                                |
+ +--------------------------------------------------------------------+
+ | This file is a part of CiviCRM.                                    |
+ |                                                                    |
+ | CiviCRM is free software; you can copy, modify, and distribute it  |
+ | under the terms of the GNU Affero General Public License           |
+ | Version 3, 19 November 2007 and the CiviCRM Licensing Exception.   |
+ |                                                                    |
+ | CiviCRM is distributed in the hope that it will be usefusul, but   |
+ | WITHOUT ANY WARRANTY; without even the implied warranty of         |
+ | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.               |
+ | See the GNU Affero General Public License for more details.        |
+ |                                                                    |
+ | You should have received a copy of the GNU Affero General Public   |
+ | License and the CiviCRM Licensing Exception along                  |
+ | with this program; if not, contact CiviCRM LLC                     |
+ | at info[AT]civicrm[DOT]org. If you have questions about the        |
+ | GNU Affero General Public License or the licensing of CiviCRM,     |
+ | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
+ +--------------------------------------------------------------------+
+ */
+
+/**
+ *
+ * @package CRM
+ * @copyright CiviCRM LLC (c) 2004-2019
+ */
+
+/**
+ * Shared parent class for recurring contribution forms.
+ */
+class CRM_Contribute_Form_ContributionRecur extends CRM_Core_Form {
+
+  /**
+   * @var int Contribution ID
+   */
+  protected $_coid = NULL;
+
+  /**
+   * @var int Contribution Recur ID
+   */
+  protected $_crid = NULL;
+
+  /**
+   * Explicitly declare the entity api name.
+   */
+  public function getDefaultEntity() {
+    return 'ContributionRecur';
+  }
+
+  /**
+   * Explicitly declare the form context.
+   */
+  public function getDefaultContext() {
+    return 'create';
+  }
+
+}
index 0e7cc9b267e440098e34f9497f98647491f67438..eab578a3725cb2048f38eb690066f4972a873209 100644 (file)
@@ -34,9 +34,7 @@
 /**
  * This class generates form components for processing a contribution.
  */
-class CRM_Contribute_Form_UpdateBilling extends CRM_Core_Form {
-  protected $_crid = NULL;
-  protected $_coid = NULL;
+class CRM_Contribute_Form_UpdateBilling extends CRM_Contribute_Form_ContributionRecur {
   protected $_mode = NULL;
 
   protected $_subscriptionDetails = NULL;
index 58f93a6fdc6f0ef37ffbaff30ecea9a25d963495..2b713af9206b1d17bac78ce63377bd3cb02fcb9a 100644 (file)
@@ -37,7 +37,7 @@
  * back in. It also uses a lot of functionality with the CRM API's, so any change
  * made here could potentially affect the API etc. Be careful, be aware, use unit tests.
  */
-class CRM_Contribute_Form_UpdateSubscription extends CRM_Core_Form {
+class CRM_Contribute_Form_UpdateSubscription extends CRM_Contribute_Form_ContributionRecur {
 
   /**
    * The recurring contribution id, used when editing the recurring contribution.
@@ -46,8 +46,6 @@ class CRM_Contribute_Form_UpdateSubscription extends CRM_Core_Form {
    */
   protected $contributionRecurID = NULL;
 
-  protected $_coid = NULL;
-
   protected $_subscriptionDetails = NULL;
 
   protected $_selfService = FALSE;
@@ -382,11 +380,4 @@ class CRM_Contribute_Form_UpdateSubscription extends CRM_Core_Form {
     }
   }
 
-  /**
-   * Explicitly declare the form context.
-   */
-  public function getDefaultContext() {
-    return 'create';
-  }
-
 }