CodeIgniter Forums
Pass values to external class - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forum-28.html)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forum-30.html)
+--- Thread: Pass values to external class (/thread-74402.html)



Pass values to external class - AKKU - 09-18-2019

Good day,
               I want to add a payment gateway to my project. For that, the payment gateway guys provided their code, now I want to pass some values from my controller to that file (Attached). The problem is the whole file is a class. I cant create my own function in it.
Code:
class NetworkonlieBitmapPaymentIntegration
{
$networkOnlineArray = array('Network_Online_setting' => array(
'MKEY'    => "REDACTED",
'MID'     => 'REDACTED',                                                              
'amount' => '1000',
'name' => 'ADCB',
'currency' => 'PHP',            
));
}
$networkOnlineObject = new NetworkonlieBitmapPaymentIntegration($networkOnlineArray);
I tried it as the library, helper even separate controller but no luck


RE: Pass values to external class - includebeer - 09-20-2019

Passing Parameters When Initializing Your Class: https://codeigniter.com/user_guide/general/creating_libraries.html#passing-parameters-when-initializing-your-class


RE: Pass values to external class - kilishan - 09-20-2019

If they don't provide a way to do what you need to do you'll have to extend the class with a new class of your own that layers the functionality you need on top of theirs. Standard PHP stuff.

PHP Code:
class MyNewClass extends NetworkonlieBitmapPaymentIntegration
{
    
// add your new functionality, calling theirs wherever you need to.