From: Eileen McNaughton Date: Wed, 7 Jan 2015 02:24:45 +0000 (+1300) Subject: CRM-15771 remove obsolete singleton functions X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=204c86d59f0cfc4c4d917cc245fb41633d36916e;p=civicrm-core.git CRM-15771 remove obsolete singleton functions --- diff --git a/CRM/Core/Payment/AuthorizeNet.php b/CRM/Core/Payment/AuthorizeNet.php index 7e891d9b96..efb0c89d9c 100644 --- a/CRM/Core/Payment/AuthorizeNet.php +++ b/CRM/Core/Payment/AuthorizeNet.php @@ -64,36 +64,6 @@ class CRM_Core_Payment_AuthorizeNet extends CRM_Core_Payment { $this->_setParam('sequence', rand(1, 1000)); } - /** - * Singleton function used to manage this object - * - * @param string $mode - * The mode of operation: live or test. - * @param array $paymentProcessor - * The details of the payment processor being invoked. - * @param CRM_Core_Form $paymentForm - * Reference to the form object if available. - * @param bool $force - * Should we force a reload of this payment object. - * - * @return object - * @static - * - */ - public static function &singleton($mode, &$paymentProcessor, &$paymentForm = NULL, $force = FALSE) { - if (!empty($paymentProcessor['id'])) { - $cacheKey = $paymentProcessor['id']; - } - else { - //@todo eliminated instances of this in favour of id-specific instances. - $cacheKey = $mode . '_' . $paymentProcessor['name']; - } - if (!isset(self::$_singleton[$cacheKey]) || self::$_singleton[$cacheKey] === NULL) { - self::$_singleton[$cacheKey] = new CRM_Core_Payment_AuthorizeNet($mode, $paymentProcessor); - } - return self::$_singleton[$cacheKey]; - } - /** * Should the first payment date be configurable when setting up back office recurring payments * In the case of Authorize.net this is an option diff --git a/CRM/Core/Payment/Dummy.php b/CRM/Core/Payment/Dummy.php index 93f07389c0..f003ff4174 100644 --- a/CRM/Core/Payment/Dummy.php +++ b/CRM/Core/Payment/Dummy.php @@ -58,33 +58,6 @@ class CRM_Core_Payment_Dummy extends CRM_Core_Payment { $this->_processorName = ts('Dummy Processor'); } - /** - * Singleton function used to manage this object - * - * @param string $mode - * The mode of operation: live or test. - * - * @param object $paymentProcessor - * @param null $paymentForm - * @param bool $force - * - * @return object - * @static - */ - public static function &singleton($mode, &$paymentProcessor, &$paymentForm = NULL, $force = FALSE) { - if (!empty($paymentProcessor['id'])) { - $cacheKey = $paymentProcessor['id']; - } - else { - //@todo eliminated instances of this in favour of id-specific instances. - $cacheKey = $mode . '_' . $paymentProcessor['name']; - } - if (CRM_Utils_Array::value($cacheKey, self::$_singleton) === NULL) { - self::$_singleton[$cacheKey] = new CRM_Core_Payment_Dummy($mode, $paymentProcessor); - } - return self::$_singleton[$cacheKey]; - } - /** * Submit a payment using Advanced Integration Method * diff --git a/CRM/Core/Payment/Elavon.php b/CRM/Core/Payment/Elavon.php index d514873e2c..79569fa36e 100644 --- a/CRM/Core/Payment/Elavon.php +++ b/CRM/Core/Payment/Elavon.php @@ -54,31 +54,6 @@ class CRM_Core_Payment_Elavon extends CRM_Core_Payment { $this->_processorName = ts('Elavon'); } - /** - * Singleton function used to manage this object - * - * @param string $mode - * The mode of operation: live or test. - * - * @param object $paymentProcessor - * - * @return object - * @static - */ - public static function &singleton($mode, &$paymentProcessor) { - if (!empty($paymentProcessor['id'])) { - $cacheKey = $paymentProcessor['id']; - } - else { - //@todo eliminated instances of this in favour of id-specific instances. - $cacheKey = $mode . '_' . $paymentProcessor['name']; - } - if (self::$_singleton[$cacheKey] === NULL) { - self::$_singleton[$cacheKey] = new CRM_Core_Payment_Elavon($mode, $paymentProcessor); - } - return self::$_singleton[$cacheKey]; - } - /********************************************************** * This function is set up and put here to make the mapping of fields * from the params object as visually clear as possible for easy editing diff --git a/CRM/Core/Payment/FirstData.php b/CRM/Core/Payment/FirstData.php index ff83bbe9f4..241d08cf62 100644 --- a/CRM/Core/Payment/FirstData.php +++ b/CRM/Core/Payment/FirstData.php @@ -78,31 +78,6 @@ class CRM_Core_Payment_FirstData extends CRM_Core_Payment { $this->_paymentProcessor = $paymentProcessor; } - /** - * Singleton function used to manage this object - * - * @param string $mode - * The mode of operation: live or test. - * - * @param object $paymentProcessor - * - * @return object - * @static - */ - public static function &singleton($mode, &$paymentProcessor) { - if (!empty($paymentProcessor['id'])) { - $cacheKey = $paymentProcessor['id']; - } - else { - //@todo eliminated instances of this in favour of id-specific instances. - $cacheKey = $mode . '_' . $paymentProcessor['name']; - } - if (self::$_singleton[$cacheKey] === NULL) { - self::$_singleton[$cacheKey] = new CRM_Core_Payment_FirstData($mode, $paymentProcessor); - } - return self::$_singleton[$cacheKey]; - } - /********************************************************** * This function is set up and put here to make the mapping of fields * from the params object as visually clear as possible for easy editing diff --git a/CRM/Core/Payment/Google.php b/CRM/Core/Payment/Google.php index bf219b8de0..5d5f7c760e 100644 --- a/CRM/Core/Payment/Google.php +++ b/CRM/Core/Payment/Google.php @@ -75,31 +75,6 @@ class CRM_Core_Payment_Google extends CRM_Core_Payment { $this->_processorName = ts('Google Checkout'); } - /** - * Singleton function used to manage this object - * - * @param string $mode - * The mode of operation: live or test. - * - * @param object $paymentProcessor - * - * @return object - * @static - */ - public static function &singleton($mode, &$paymentProcessor) { - if (!empty($paymentProcessor['id'])) { - $cacheKey = $paymentProcessor['id']; - } - else { - //@todo eliminated instances of this in favour of id-specific instances. - $cacheKey = $mode . '_' . $paymentProcessor['name']; - } - if (!isset(self::$_singleton[$cacheKey]) || self::$_singleton[$cacheKey] === NULL) { - self::$_singleton[$cacheKey] = new CRM_Core_Payment_Google($mode, $paymentProcessor); - } - return self::$_singleton[$cacheKey]; - } - /** * This function checks to see if we have the right config values * diff --git a/CRM/Core/Payment/GoogleIPN.php b/CRM/Core/Payment/GoogleIPN.php index 6dbd487545..595b2271c5 100644 --- a/CRM/Core/Payment/GoogleIPN.php +++ b/CRM/Core/Payment/GoogleIPN.php @@ -397,6 +397,8 @@ WHERE contribution_recur_id = {$ids['contributionRecur']} } /** + * @deprecated + * Payment processor singletons removed - this is an IPN so left but probably can go * Singleton function used to manage this object * * @param string $mode diff --git a/CRM/Core/Payment/IATS.php b/CRM/Core/Payment/IATS.php index 616d26d288..8c4f9a47fb 100644 --- a/CRM/Core/Payment/IATS.php +++ b/CRM/Core/Payment/IATS.php @@ -75,27 +75,6 @@ class CRM_Core_Payment_IATS extends CRM_Core_Payment { } } - /** - * @param string $mode - * @param array $paymentProcessor - * - * @return mixed - */ - public static function &singleton($mode, &$paymentProcessor) { - if (!empty($paymentProcessor['id'])) { - $cacheKey = $paymentProcessor['id']; - } - else { - //@todo eliminated instances of this in favour of id-specific instances. - $cacheKey = $mode . '_' . $paymentProcessor['name']; - } - - if (self::$_singleton[$cacheKey] === NULL) { - self::$_singleton[$cacheKey] = new CRM_Core_Payment_IATS($mode, $paymentProcessor); - } - return self::$_singleton[$cacheKey]; - } - /** * This function collects all the information from a web/api form and invokes * the relevant payment processor specific functions to perform the transaction diff --git a/CRM/Core/Payment/Moneris.php b/CRM/Core/Payment/Moneris.php index 5226b9ca46..d86b48da46 100644 --- a/CRM/Core/Payment/Moneris.php +++ b/CRM/Core/Payment/Moneris.php @@ -79,31 +79,6 @@ class CRM_Core_Payment_Moneris extends CRM_Core_Payment { } } - /** - * Singleton function used to manage this object - * - * @param string $mode - * The mode of operation: live or test. - * - * @param object $paymentProcessor - * - * @return object - * @static - */ - public static function &singleton($mode, &$paymentProcessor) { - if (!empty($paymentProcessor['id'])) { - $cacheKey = $paymentProcessor['id']; - } - else { - //@todo eliminated instances of this in favour of id-specific instances. - $cacheKey = $mode . '_' . $paymentProcessor['name']; - } - if (self::$_singleton[$cacheKey] === NULL) { - self::$_singleton[$cacheKey] = new CRM_Core_Payment_Moneris($mode, $paymentProcessor); - } - return self::$_singleton[$cacheKey]; - } - /** * This function collects all the information from a web/api form and invokes * the relevant payment processor specific functions to perform the transaction diff --git a/CRM/Core/Payment/PayJunction.php b/CRM/Core/Payment/PayJunction.php index c25ea1fb3e..0c7c73bb30 100644 --- a/CRM/Core/Payment/PayJunction.php +++ b/CRM/Core/Payment/PayJunction.php @@ -47,33 +47,6 @@ class CRM_Core_Payment_PayJunction extends CRM_Core_Payment { $this->_processorName = ts('PayJunction'); } - /** - * Singleton function used to manage this object - * - * @param string $mode - * The mode of operation: live or test. - * - * @param object $paymentProcessor - * @param null $paymentForm - * @param bool $force - * - * @return object - * @static - */ - public static function &singleton($mode, &$paymentProcessor, &$paymentForm = NULL, $force = FALSE) { - if (!empty($paymentProcessor['id'])) { - $cacheKey = $paymentProcessor['id']; - } - else { - //@todo eliminated instances of this in favour of id-specific instances. - $cacheKey = $mode . '_' . $paymentProcessor['name']; - } - if (self::$_singleton[$cacheKey] === NULL) { - self::$_singleton[$cacheKey] = new CRM_Core_Payment_PayJunction($mode, $paymentProcessor); - } - return self::$_singleton[$cacheKey]; - } - /* * This function sends request and receives response from * PayJunction payment process diff --git a/CRM/Core/Payment/PayPalImpl.php b/CRM/Core/Payment/PayPalImpl.php index 0368b5c362..84199205af 100644 --- a/CRM/Core/Payment/PayPalImpl.php +++ b/CRM/Core/Payment/PayPalImpl.php @@ -75,33 +75,6 @@ class CRM_Core_Payment_PayPalImpl extends CRM_Core_Payment { } } - /** - * Singleton function used to manage this object - * - * @param string $mode - * The mode of operation: live or test. - * - * @param object $paymentProcessor - * @param null $paymentForm - * @param bool $force - * - * @return object - * @static - */ - public static function &singleton($mode, &$paymentProcessor, &$paymentForm = NULL, $force = FALSE) { - if (!empty($paymentProcessor['id'])) { - $cacheKey = $paymentProcessor['id']; - } - else { - //@todo eliminated instances of this in favour of id-specific instances. - $cacheKey = $mode . '_' . $paymentProcessor['name']; - } - if (!isset(self::$_singleton[$cacheKey]) || self::$_singleton[$cacheKey] === NULL) { - self::$_singleton[$cacheKey] = new CRM_Core_Payment_PaypalImpl($mode, $paymentProcessor); - } - return self::$_singleton[$cacheKey]; - } - /** * Are back office payments supported - e.g paypal standard won't permit you to enter a credit card associated with someone else's login * @return bool diff --git a/CRM/Core/Payment/PayflowPro.php b/CRM/Core/Payment/PayflowPro.php index 0ecaa28ba7..e098426081 100644 --- a/CRM/Core/Payment/PayflowPro.php +++ b/CRM/Core/Payment/PayflowPro.php @@ -45,31 +45,6 @@ class CRM_Core_Payment_PayflowPro extends CRM_Core_Payment { $this->_processorName = ts('Payflow Pro'); } - /** - * Singleton function used to manage this object - * - * @param string $mode - * The mode of operation: live or test. - * - * @param object $paymentProcessor - * - * @return object - * @static - */ - public static function &singleton($mode, &$paymentProcessor) { - if (!empty($paymentProcessor['id'])) { - $cacheKey = $paymentProcessor['id']; - } - else { - //@todo eliminated instances of this in favour of id-specific instances. - $cacheKey = $mode . '_' . $paymentProcessor['name']; - } - if (self::$_singleton[$cacheKey] === NULL) { - self::$_singleton[$cacheKey] = new CRM_Core_Payment_PayflowPro($mode, $paymentProcessor); - } - return self::$_singleton[$cacheKey]; - } - /* * This function sends request and receives response from * the processor. It is the main function for processing on-server diff --git a/CRM/Core/Payment/PaymentExpress.php b/CRM/Core/Payment/PaymentExpress.php index ffe15b8abb..fdc6a146aa 100644 --- a/CRM/Core/Payment/PaymentExpress.php +++ b/CRM/Core/Payment/PaymentExpress.php @@ -67,33 +67,6 @@ class CRM_Core_Payment_PaymentExpress extends CRM_Core_Payment { $this->_processorName = ts('DPS Payment Express'); } - /** - * Singleton function used to manage this object - * - * @param string $mode - * The mode of operation: live or test. - * - * @param object $paymentProcessor - * @param null $paymentForm - * @param bool $force - * - * @return object - * @static - */ - public static function &singleton($mode = 'test', &$paymentProcessor, &$paymentForm = NULL, $force = FALSE) { - if (!empty($paymentProcessor['id'])) { - $cacheKey = $paymentProcessor['id']; - } - else { - //@todo eliminated instances of this in favour of id-specific instances. - $cacheKey = $mode . '_' . $paymentProcessor['name']; - } - if (self::$_singleton[$cacheKey] === NULL) { - self::$_singleton[$cacheKey] = new CRM_Core_Payment_PaymentExpress($mode, $paymentProcessor); - } - return self::$_singleton[$cacheKey]; - } - /** * This function checks to see if we have the right config values * diff --git a/CRM/Core/Payment/PaymentExpressIPN.php b/CRM/Core/Payment/PaymentExpressIPN.php index 8ad592d8b8..f500076b99 100644 --- a/CRM/Core/Payment/PaymentExpressIPN.php +++ b/CRM/Core/Payment/PaymentExpressIPN.php @@ -98,26 +98,6 @@ class CRM_Core_Payment_PaymentExpressIPN extends CRM_Core_Payment_BaseIPN { $this->_paymentProcessor = $paymentProcessor; } - /** - * Singleton function used to manage this object - * - * @param string $mode - * The mode of operation: live or test. - * - * @param $paymentProcessor - * @param null $paymentForm - * @param bool $force - * - * @return object - * @static - */ - public static function &singleton($mode = 'test', &$paymentProcessor, &$paymentForm = NULL, $force = FALSE) { - if (self::$_singleton === NULL) { - self::$_singleton = new CRM_Core_Payment_PaymentExpressIPN($mode, $paymentProcessor); - } - return self::$_singleton; - } - /** * The function gets called when a new order takes place. * diff --git a/CRM/Core/Payment/ProcessorForm.php b/CRM/Core/Payment/ProcessorForm.php index 114b527607..4161479355 100644 --- a/CRM/Core/Payment/ProcessorForm.php +++ b/CRM/Core/Payment/ProcessorForm.php @@ -61,7 +61,7 @@ class CRM_Core_Payment_ProcessorForm { // also set cancel subscription url if (!empty($form->_paymentProcessor['is_recur']) && !empty($form->_values['is_recur'])) { - $form->_paymentObject = &CRM_Core_Payment::singleton($mode, $form->_paymentProcessor, $form); + $form->_paymentObject = CRM_Core_Payment::singleton($mode, $form->_paymentProcessor, $form); $form->_values['cancelSubscriptionUrl'] = $form->_paymentObject->subscriptionURL(); } diff --git a/CRM/Core/Payment/Realex.php b/CRM/Core/Payment/Realex.php index c1901c6001..02f1363ddb 100644 --- a/CRM/Core/Payment/Realex.php +++ b/CRM/Core/Payment/Realex.php @@ -78,31 +78,6 @@ class CRM_Core_Payment_Realex extends CRM_Core_Payment { $this->_setParam('sequence', rand(1, 1000)); } - /** - * Singleton function used to manage this object - * - * @param string $mode - * The mode of operation: live or test. - * - * @param object $paymentProcessor - * - * @return object - * @static - */ - public static function &singleton($mode, &$paymentProcessor, &$paymentForm = NULL, $force = FALSE) { - if (!empty($paymentProcessor['id'])) { - $cacheKey = $paymentProcessor['id']; - } - else { - //@todo eliminated instances of this in favour of id-specific instances. - $cacheKey = $mode . '_' . $paymentProcessor['name']; - } - if (self::$_singleton[$cacheKey] === NULL) { - self::$_singleton[$cacheKey] = new CRM_Core_Payment_Realex($mode, $paymentProcessor); - } - return self::$_singleton[$cacheKey]; - } - /** * @param array $params * diff --git a/CRM/Core/Payment/eWAY.php b/CRM/Core/Payment/eWAY.php index 4dfce475e7..ea00761daf 100644 --- a/CRM/Core/Payment/eWAY.php +++ b/CRM/Core/Payment/eWAY.php @@ -124,34 +124,6 @@ class CRM_Core_Payment_eWAY extends CRM_Core_Payment { $this->_processorName = ts('eWay'); } - /** - * Singleton function used to manage this object - * - * @param string $mode - * The mode of operation: live or test. - * - * @param object $paymentProcessor - * @param null $paymentForm - * @param bool $force - * - * @return object - * @static - */ - public static function &singleton($mode, &$paymentProcessor, &$paymentForm = NULL, $force = FALSE) { - if (!empty($paymentProcessor['id'])) { - $cacheKey = $paymentProcessor['id']; - } - else { - //@todo eliminated instances of this in favour of id-specific instances. - $cacheKey = $mode . '_' . $paymentProcessor['name']; - } - - if (self::$_singleton[$cacheKey] === NULL) { - self::$_singleton[$cacheKey] = new CRM_Core_Payment_eWAY($mode, $paymentProcessor); - } - return self::$_singleton[$cacheKey]; - } - /********************************************************** * This function sends request and receives response from * eWAY payment process