[TYPO3-paymentlib] unexpected returned object from tx_paymentlib_providerfactory::getProviderObjectByPaymentMethod

Franz Holzinger franz at fholzinger.com
Fri Jul 27 13:25:36 CEST 2007


Hello,

according to the name the method getProviderObjectByPaymentMethod should
return the providerObject for the specific gateway. It however returns
the providerProxyObject and not the real providerObject behind.
So line 104 in class.tx_paymentlib_providerfactory.php should be fixed
to this:
return $providerProxyObject->getRealInstance();

And AFAIK in PHP5 the instance to it will be returned and no new object
will be copied in memory here.

The providerObject has been registered with

$providerFactoryObj = &tx_paymentlib_providerfactory::getInstance();
$providerFactoryObj->registerProviderClass ('tx_paymentlibpaypal_provider');

Then a providerProxyClass is created internally. This is fine, however
this has not been intended by the caller and the internals should be
hidden to him.

Can anybody confirm this is a bug?

Or otherwise the function should be copied under the new name to
getProviderProxyObjectByPaymentMethod to avoid confusion.

- Franz

-----------------------------------------------

/**
 * Returns instance of the payment implementations (wrapped by a proxy
 * object) which offers the specified payment method.
 *
 * @param		string		$paymentMethod: Payment method key
 * @return		mixed		Reference to payment proxy object or FALSE if no
matching object was found
 * @access		public
 */
public function getProviderObjectByPaymentMethod($paymentMethod) {
	if (is_array ($this->providerProxyObjects)) {
		foreach ($this->providerProxyObjects as $providerClass =>
$providerProxyObject) {
			$paymentMethodsArr = $providerProxyObject->getAvailablePaymentMethods();
			if (array_key_exists ($paymentMethod, $paymentMethodsArr)) {
				return $providerProxyObject;
			}
		}	
	}
	return FALSE;
}


More information about the TYPO3-project-paymentlib mailing list