CiviCRM Community > Extensions
Bootstrapping CiviCRM and talking to extensions
(1/1)
grobot:
Related to current discussion (other thread) about IPN callbacks, in the meantime I want to fire up CiviCRM and start using some methods implemented in extension classes.
I noticed that the Ogone processor IPN references CRM_Core_Payment_OgoneIPN::main without even having to include the class file. "Great!", I thought, "CiviCRM must automatically load the core file from each extension. Easy!". Nope.
So I did this instead:
--- Code: ---session_start( );
require_once '../civicrm.config.php';
require_once 'CRM/Core/Config.php';
$config = CRM_Core_Config::singleton();
// Probably there's a cleaner way to require an extension's base file?
require_once 'CRM/Core/Extensions/Extension.php';
$ext = new CRM_Core_Extensions_Extension( 'nz.co.giantrobot.flo2cashdonate' );
if ( !empty( $ext->path ) ) {
require_once $ext->path . '/Flo2CashDonate.php';
}
--- End code ---
https://github.com/GiantRobot/civicrm_flo2cash_donate/blob/master/nz.co.giantrobot.flo2cashdonate/f2c_ipn.php#L9
Is there an easier, cleaner way to achieve this? If there was then f2c_ipn.php would more like ten lines than thirty.
MichaĆ Mach:
My first impression is that that's the best way, nothing cleaner comes to mind - you're in "external script" which doesn't know where the actual extensions is at the moment.
Thx,
m
Navigation
[0] Message Index
Go to full version