mirror of
https://github.com/FOSSBilling/FOSSBilling.git
synced 2026-11-30 04:07:07 +09:00
Move Payment Gateways into folders (#630)
* Update ServicePayGateway * Resolve issues with crappy naming * Resolve issues with auto loading
This commit is contained in:
1 parent
042e056b8e
commit
5f4e400dfa
1 file changed
+20
-2
@@ -92,6 +92,16 @@ class ServicePayGateway implements InjectionAwareInterface
|
||||
$adapters[] = $adapter;
|
||||
}
|
||||
}
|
||||
$pattern = PATH_LIBRARY . '/Payment/Adapter/*/*.php';
|
||||
foreach (glob($pattern) as $path) {
|
||||
$directory = explode('/',pathinfo($path, PATHINFO_DIRNAME));
|
||||
$adapter = end($directory);
|
||||
if (!array_key_exists($adapter, $exists)) {
|
||||
if($path == PATH_LIBRARY . '/Payment/Adapter/'.$adapter.'/'.$adapter.'.php'){
|
||||
$adapters[] = $adapter;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $adapters;
|
||||
}
|
||||
@@ -265,7 +275,9 @@ class ServicePayGateway implements InjectionAwareInterface
|
||||
{
|
||||
$class = $this->getAdapterClassName($pg);
|
||||
if (!file_exists(PATH_LIBRARY . '/Payment/Adapter/' . $pg->gateway . '.php')) {
|
||||
throw new \Box_Exception('Payment gateway :adapter was not found', [':adapter' => $pg->gateway]);
|
||||
if(!file_exists(PATH_LIBRARY . '/Payment/Adapter/' . $pg->gateway . '/'.$pg->gateway.'.php')){
|
||||
throw new \Box_Exception('Payment gateway :adapter was not found', [':adapter' => $pg->gateway]);
|
||||
}
|
||||
}
|
||||
|
||||
if (!class_exists($class)) {
|
||||
@@ -283,7 +295,13 @@ class ServicePayGateway implements InjectionAwareInterface
|
||||
|
||||
public function getAdapterClassName(\Model_PayGateway $pg)
|
||||
{
|
||||
return sprintf('Payment_Adapter_%s', $pg->gateway);
|
||||
$class = sprintf('Payment_Adapter_%s', $pg->gateway);
|
||||
if(!class_exists($class)){
|
||||
include PATH_LIBRARY . '/Payment/Adapter/' . $pg->gateway . '/'.$pg->gateway.'.php';
|
||||
return sprintf('Payment_Adapter_%s', $pg->gateway);
|
||||
}else{
|
||||
return $class;
|
||||
}
|
||||
}
|
||||
|
||||
public function getAcceptedCurrencies(\Model_PayGateway $model)
|
||||
|
||||
Reference in new issue
Block a user